Advertisement
Guest User

Untitled

a guest
Aug 12th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3.  
  4. class Animal
  5.  
  6. attr_reader :name, :age
  7.  
  8. def initialize(name, age)
  9. @name = name
  10. @age = age
  11. end
  12.  
  13. end
  14.  
  15. class Dog < Animal
  16.  
  17. def self.check_name
  18. puts "hello dog" if name =~ /perla/
  19. end
  20.  
  21. end
  22.  
  23. dog = Dog.new("perla", 7)
  24.  
  25. puts dog.name
  26. dog.check_name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement