B
Brian Schröder
Just a minor typo in the documentation
-------------------------------------------------- Kernel#method_missing
obj.method_missing(symbol [, *args] ) => result
------------------------------------------------------------------------
Invoked by Ruby when obj is sent a message it cannot handle.
symbol is the symbol for the method called, and args are any
arguments that were passed to it. By default, the interpreter
raises an error when this method is called. However, it is
possible to override the method to provide more dynamic behavior.
The example below creates a class Roman, which responds to methods
with names consisting of roman numerals, returning the
corresponding integer values.
class Roman
def romanToInt(str)
# ...
end
def method_missing(methId)
str = methId.id2name
romanToInt(str)
end
end
r = Roman.new
r.iv #=> 4
r.xxiii #=> 23
r.mm #=> 2000
I think that it would make sense to gsub(/methId/, 'meth_id') to go with standard ruby dialect.
Regards,
Brian
-------------------------------------------------- Kernel#method_missing
obj.method_missing(symbol [, *args] ) => result
------------------------------------------------------------------------
Invoked by Ruby when obj is sent a message it cannot handle.
symbol is the symbol for the method called, and args are any
arguments that were passed to it. By default, the interpreter
raises an error when this method is called. However, it is
possible to override the method to provide more dynamic behavior.
The example below creates a class Roman, which responds to methods
with names consisting of roman numerals, returning the
corresponding integer values.
class Roman
def romanToInt(str)
# ...
end
def method_missing(methId)
str = methId.id2name
romanToInt(str)
end
end
r = Roman.new
r.iv #=> 4
r.xxiii #=> 23
r.mm #=> 2000
I think that it would make sense to gsub(/methId/, 'meth_id') to go with standard ruby dialect.
Regards,
Brian