I'm very new to ruby. I have to code in ruby at work and a coworker gave me some tests he wrote in ruby. I have some difficulties to understand a line he wrote.
We have a class like this:
class Port
attr_accessor :nature, :name
def initialize(name)
@name = name
end
end
The test consists in:
x_port = Port.new("x")
x_port.nature = :sampling
x_port.wont_be_nil
x_port.nature.name.must_equal :sampling
I have some trouble to understand the last line, the nature.name
. I understand that we are demanding the name of the symbol but this method doesn't exist and I can't create a method name name
because of the symbol :name
already there. Can someone enlighten me of how to resolve this problem?
Thanks a lot