[Documentation Bug] Method Missing

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
 
B

Brian Schröder

Another Thing I noticed. (I checked against the documentation at ruby-doc org. I hope that is the newest version.)


--------------------------------------------------------- Object#methods
obj.methods => array
------------------------------------------------------------------------
Returns a list of the names of methods publicly accessible in obj.
This will include all the methods accessible in obj's ancestors.

class Klass
def kMethod()
end
end
k = Klass.new
k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?",
"class", "instance_variable_set",
"methods", "extend", "<em>send</em>", "instance_eval"]
k.methods.length #=> 42


$ ruby -v
ruby 1.8.2 (2004-11-03) [i386-linux]

$ irb --prompt-mode xmp
class Klass
def kMethod()
end
end
==>nil
k = Klass.new
==>#<Klass:0x402c00a4>
k.methods[0..9]
==>["clone", "protected_methods", "kMethod", "freeze", "instance_variable_set", "is_a?", "type", "methods", "method", "=~"]
k.methods.length
==>41


And additionally, here is again the snake_case against CamelCase issue.

Regards,

Brian
 
D

Dave Thomas

Another Thing I noticed. (I checked against the documentation at
ruby-doc org. I hope that is the newest version.)
k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?",
"class", "instance_variable_set",
"methods", "extend", "<em>send</em>",
"instance_eval"]
k.methods.length #=> 42
k.methods[0..9]
==>["clone", "protected_methods", "kMethod", "freeze",
"instance_variable_set", "is_a?", "type", "methods", "method", "=~"]
k.methods.length
==>41

The documentation is correct, but the list of methods in Object has
changed.


As a matter of interest, are the ruby-doc folks now maintaining the
documentation?


Cheers

Dave
 
G

Gavin Sinclair

As a matter of interest, are the ruby-doc folks now maintaining the
documentation?

No. When I get my CVS account back [1], the answer will be yes.

Gavin

[1] i.e. when I work out how to use GPG and SSH correctly.
 
B

Brian Schröder

Another Thing I noticed. (I checked against the documentation at
ruby-doc org. I hope that is the newest version.)
k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?",
"class", "instance_variable_set",
"methods", "extend", "<em>send</em>",
"instance_eval"]
k.methods.length #=> 42
k.methods[0..9]
==>["clone", "protected_methods", "kMethod", "freeze",
"instance_variable_set", "is_a?", "type", "methods", "method", "=~"]
k.methods.length
==>41

The documentation is correct, but the list of methods in Object has
changed.


As a matter of interest, are the ruby-doc folks now maintaining the
documentation?


Cheers

Dave

And regarding the two snake_case vs camelCase issues is this going to be changed?

Regards,

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top