On 07.12.2010 05:56, Matt Slay wrote:
>> x = @tolerance2.send(@size[2])
>
> Thanks, Robert, this does work fine....
>
> However, in further studies on this topic, I have stumbled across the
> attributes() method, which seems like a more sensibly named thing to
> see in code, and appears to accomplish the same thing.
>
> x = @tolerance2.attributes[@size[2]]
>
> Any reason that one is better than the other in my case. I can see that
> send() can even call a method, and that could be useful, but in this
> case, I am specifically looking for an attribute value by it's name.

irb(main):009:0> class Foo
irb(main):010:1> attr_accessor :bar
irb(main):011:1> end
=> nil
irb(main):012:0> f=Foo.new
=> #<Foo:0x10586f08>
irb(main):013:0> f.attributes
NoMethodError: undefined method `attributes' for #<Foo:0x10586f08>
         from (irb):13
         from /usr/local/bin/irb19:12:in `<main>'

The method you are mentioning must be part of some extension or other 
version of Ruby (I used 1.9.1).  If you use that anyway you can as well 
use that method.  If not, you need to decide if you want to add that 
dependency to your code.

Kind regards

	robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/