Calling class method in instance method of another class

What is the best way of calling a class method in an instance method of
a different class?

I have required the class of the class method at the top of my file, but
Ruby keeps giving me an 'uninitialized constant' error when is sees the
class name.

Has it something to do with visibility?

···

--
Posted via http://www.ruby-forum.com/.

Could you give a concrete example? Right now your question is very
abstract, and it sounds as if you're doing everything right, so the devil's
most likely in the details.

···

On 23/10/2012 8:32 AM, "Joz Private" <lists@ruby-forum.com> wrote:

What is the best way of calling a class method in an instance method of
a different class?

I have required the class of the class method at the top of my file, but
Ruby keeps giving me an 'uninitialized constant' error when is sees the
class name.

Has it something to do with visibility?

--
Posted via http://www.ruby-forum.com/\.

my_classes.rb

···

----------
class Dog
  def self.count
    10
  end
end

my_prog.rb
----------
require './my_classes.rb'

puts Dog.count

$ ruby my_prog.rb
10
$

--
Posted via http://www.ruby-forum.com/.

Absolutely. This works very simple:

$ ruby x.rb
yes!
$ cat -n x.rb
     1
     2
     3 class A
     4 def self.foo() puts "yes!" end
     5 end
     6
     7 class B
     8 def bar
     9 A.foo
    10 end
    11 end
    12
    13 B.new.bar

Cheers

robert

···

On Tue, Oct 23, 2012 at 12:18 AM, Arlen Christian Mart Cuss <ar@len.me> wrote:

Could you give a concrete example? Right now your question is very abstract,
and it sounds as if you're doing everything right, so the devil's most
likely in the details.

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/