Ruby class inheritance of included gems
class Foo
require 'somegem'
end
class Bar < Foo
def to_开发者_JS百科s
puts Somegem.somemethod
end
end
Why is this not working/how can I get something like this to work?
$ cat somegem.rb
class Somegem
def self.somemethod
"somemethod"
end
end
$ cat foo.rb
class Foo
require 'somegem'
end
class Bar < Foo
def to_s
puts Somegem.somemethod
end
end
bar = Bar.new()
bar.to_s
$ ruby foo.rb
somemethod
But I'm not exactly sure though, what you tried to accomplish ...
精彩评论