Is there anyway to get all the class with their instance methods names
to be available and to see them in the IRB terminal itself?
I am using Nokogiri and Selenium- web driver.
If not found “Google” is the only option I know
Thanks
Is there anyway to get all the class with their instance methods names
to be available and to see them in the IRB terminal itself?
I am using Nokogiri and Selenium- web driver.
If not found “Google” is the only option I know
Thanks
oO have you ever seen Class.instance_methods ?
or ObjectSpace.each_object(Class)
it looks that you are not even tryed to “google”
Hans M. wrote in post #1095417:
oO have you ever seen Class.instance_methods ?
or ObjectSpace.each_object(Class)
it looks that you are not even tryed to “google”
It seems you didn’t get my questions.
Thanks
On 02/05/2013 01:46 PM, Love U Ruby wrote:
Is there anyway to get all the class with their instance methods names
to be available and to see them in the IRB terminal itself?I am using Nokogiri and Selenium- web driver.
If not found “Google” is the only option I know
Thanks
You mean print out all the classes and their instance methods?
This should work:
ObjectSpace.each_object do |o|
if o.is_a? Class
puts “Class: #{o}”
puts o.instance_methods.sort.inspect
end
end
This doesn’t include modules, though…
-Justin
Justin C. wrote in post #1095419:
On 02/05/2013 01:46 PM, Love U Ruby wrote:
This should work:
ObjectSpace.each_object do |o|
if o.is_a? Class
puts “Class: #{o}”
puts o.instance_methods.sort.inspect
end
endThis doesn’t include modules, though…
-Justin
Yes, you are right. But does it give me the Ruby gem methods also. In my
case it is nokogiri and selenium webdriver?
run gem server in your shell, then access localhost:8880
pick the gem: for sample “nokogiri 1.5.6 [rdoc]” klick on [rdoc]
and you get an list of classes and methods this one gem installs
inside irb its more comlicated
you could try:
l = ObjectSpace.each_object(Class).to_a
require “nokogiri”
ObjectSpace.each_object(Class).to_a - l
but it also show classes required by nokogiri
you still react like some that is to lazy to google … (and this is not
your first thread where it looks like that)
I guess I don’t understand why you (Love U Ruby) want to go through so
much trouble to avoid going and looking at the documentation for the
gems. Although, given that so many of of your posts (Even when you had
your old name of “Arup R.”) have suggested that other people do the
reading for you, I guess it makes sense.
The code provided by Justin C. would give you all of the methods
for instances of the current Objects that are in memory (in that
instance of the ruby vm). This should give you what you’re looking for,
even for the Gems (assuming the object you’re working with/looking for
has been instantiated). I’m still 100% sure that you will have better
luck looking at the documentation for the gems, they will be more
complete and help you better than just looking at output in irb.
-Ryan
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs