ruby - How to get classes interact with one another -


i have classes person, dogs, cats, , fishes, , need them interact. more specifically, need person class buy instance of dog class, or name instance of cat class, etc.

how do that? variables class variables, out of scope use in class. not sure start.

let's have person.rb:

class person  ....... end 

and have dog.rb:

class dog  ........ end 

if want access dog class inside person have include it. means dog.rb be:

require 'dog'  class person   def my_method     dog = dog.new()   end end 

require 'name_of_file_with_class'

this pure example how make accessible, furthermore depends on want.

cheers.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -