String[lastchar] -> string?

Ibraheem Ibz Umaru-Mohammed [mailto:iumarumo@btinternet.com] informs:

I usually just fire up the interpreter, and do something like:

ibz@ignoramus:$ irb
Reading config file… done.
ruby-1.7.3 on i686-pc-linux with irb 0.9(02/07/03)
Type ‘help’ for more information.

String.methods.sort
[“<”, “<=”, “<=>”, “==”, “===”, “=~”, “>”, “>=”, “id”,
send”, “allocate”, “ancestors”, “become”, “class”,
“class_eval”, “class_variables”, “clone”, “const_defined?”,
“const_get”, “const_set”, “constants”, “display”, “dup”,
“eql?”, “equal?”, “extend”, “freeze”, “frozen?”, “hash”,
“id”, “include?”, “included_modules”, “inspect”,
“instance_eval”, “instance_method”, “instance_methods”,
“instance_of?”, “instance_variables”, “is_a?”, “kind_of?”,
“method”, “method_defined?”, “methods”, “module_eval”,
“name”, “new”, “nil?”, “private_class_method”,
“private_instance_methods”, “private_methods”,
“protected_instance_methods”, “protected_methods”,
“public_class_method”, “public_instance_methods”,
“public_methods”, “respond_to?”, “send”, “singleton_methods”,
“superclass”, “taint”, “tainted?”, “to_a”, “to_s”, “type”, “untaint”]

Also, although you won’t be using the code above, you’ll find you’ve
forgotten a “=” and a “!” somewhere in there :wink:

  	--ibz.

Hi Ibraheem,

I tried String.methods[40] n and got “to_a”.

Is it possible to do String.methods[40].man (or something like that) so that
it will output a manual-like page whose output is similar to ri’s
String.methods.to_a ?

many thanks -botp

Ibraheem Ibz Umaru-Mohammed [mailto:iumarumo@btinternet.com] informs:

I usually just fire up the interpreter, and do something like:

ibz@ignoramus:$ irb
Reading config file… done.
ruby-1.7.3 on i686-pc-linux with irb 0.9(02/07/03)
Type ‘help’ for more information.

String.methods.sort
[“<”, “<=”, “<=>”, “==”, “===”, “=~”, “>”, “>=”, “id”,
send”, “allocate”, “ancestors”, “become”, “class”,
“class_eval”, “class_variables”, “clone”, “const_defined?”,
“const_get”, “const_set”, “constants”, “display”, “dup”,
“eql?”, “equal?”, “extend”, “freeze”, “frozen?”, “hash”,
“id”, “include?”, “included_modules”, “inspect”,
“instance_eval”, “instance_method”, “instance_methods”,
“instance_of?”, “instance_variables”, “is_a?”, “kind_of?”,
“method”, “method_defined?”, “methods”, “module_eval”,
“name”, “new”, “nil?”, “private_class_method”,
“private_instance_methods”, “private_methods”,
“protected_instance_methods”, “protected_methods”,
“public_class_method”, “public_instance_methods”,
“public_methods”, “respond_to?”, “send”, “singleton_methods”,
“superclass”, “taint”, “tainted?”, “to_a”, “to_s”, “type”, “untaint”]
[— snip —]
Hi Ibraheem,

I tried String.methods[40] n and got “to_a”.

That magic number “40” seems a little strange to me.
In the example above, I used String.methods.sort, just
to get a sorted listing of the methods for “String”. “ri” does a
sorted listing, similar to the above, which can be invoked from the
command-line.

Is it possible to do String.methods[40].man (or something like that) so that
it will output a manual-like page whose output is similar to ri’s
String.methods.to_a ?

No. But then again, am not sure what you are after here. Are you trying to get
“ri”-like output from within the interpreter?

many thanks -botp

			--ibz.
···

See the thread beginning at [ruby-talk:30225]. I wanted to see how
few lines were needed to get in Ruby a feature that some Pythonists
were constantly bugging about. :wink: Guy Decoux contributed some fixes
and ideas offlist, so you won’t find it all in the archives, but if
you feel adventurous, I can forward it to you. :slight_smile:

Massimiliano

···

On Mon, Oct 21, 2002 at 10:00:02AM +0900, “Peña, Botp” wrote:

I tried String.methods[40] n and got “to_a”.

Is it possible to do String.methods[40].man (or something like that)