Exposing Ancestor Public Methods/ Book Reccomendation

D

Demonic Software

[Note: parts of this message were removed to make it a legal post.]

Hello,

I am trying to access some attr_accessor and public/protected methods from
an inheriting class or module.

class Foo:
def initialize(); end
def some_method():
print "Foo are you?\n"
end
end

class Bar < Foo
class << self; end
def initialize(); end
def another_method()
print "Bar am I"
end
end

If I do a Foo.public_methods, it will list some_method as one of those
methods. I am trying to get Bar.public_method to also list that inherited
method.Is this possible?
Is there also a way to force this inheritance with instance variables?
Likewise I would like to do perform the same activities on modules, and is
that possible (example below of how I am doing this)?

module Foo:
def some_method():
print "Foo are you?\n"
end
end

class Bar < Foo
class << self; end
def initialize(); end
def another_method()
print "Bar am I"
end
end

Also, is there book that speaks about the core aspects of Ruby programming,
giving detailed Networking, thread programming, etc. Basically, I am
looking for a general reference book that covers a wide range of areas in
Ruby programming, which are accompanied by examples. Additionally, the
topics do not need to cover Ruby on Rails. Thanks.
 
A

Avdi Grimm

Also, is there book that speaks about the core aspects of Ruby programming,
giving detailed Networking, thread programming, etc. Basically, I am
looking for a general reference book that covers a wide range of areas in
Ruby programming, which are accompanied by examples. Additionally, the
topics do not need to cover Ruby on Rails. Thanks.

You need "The Ruby Way", Second Edition, by Hal Fulton.
 

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

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top