Guest User

Untitled

a guest
Feb 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. class Dog
  2. attr_accessor :animal_type
  3. %w(cats dogs rabbits pigs cows).each do |t|
  4. define_method "has_#{t}" do |number|
  5. @animal_type = t
  6. puts number
  7. end
  8. end
  9. end
  10.  
  11. d = Dog.new
  12. d.has_dogs 10
  13. puts d.animal_type
  14. p d.methods.sort
Add Comment
Please, Sign In to add comment