Guest User

Untitled

a guest
Feb 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. class Dog
  2. attr_accessor :number_of_computers
  3. def method_missing(name, *args)
  4. name = name.to_s
  5. name =~ /has_(\d+)_computers/
  6. @number_of_computers = $1.to_i
  7. end
  8. end
  9.  
  10. d = Dog.new
  11. d.has_20_computers
  12. puts d.number_of_computers
Add Comment
Please, Sign In to add comment