Created
February 7, 2017 16:17
-
-
Save RubyBrewsday/1e71ced4023959ebf14ead5ce5037759 to your computer and use it in GitHub Desktop.
Cause we all got it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tiger | |
def initialize | |
@eyes = Eye.new(2) | |
end | |
def eye | |
@eyes.count > 1 ? 1 : 0 | |
end | |
end | |
class Eye | |
attr_reader :count | |
def initialize(count) | |
@count = count | |
end | |
end | |
class Person | |
def initialize(name) | |
@name = name | |
end | |
def got(attribute, object) | |
puts "{@name} got #{object.send(attribute)} #{attribute} of the #{object}" | |
end | |
end | |
i = Person.new("me") | |
i.got("eye", Tiger.new) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment