Created
August 4, 2013 02:12
Revisions
-
There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ class Bob def hey(phrase) think_about(heard(phrase)).respond end def heard(phrase) String(phrase) end def think_about(might_have_heard) THOUGHTS.find(-> { Default }) { |thought| thought.heard?(might_have_heard) } end class << Silent = Object.new def heard?(other) other.empty? end def respond "Fine. Be that way." end end class << Question = Object.new def heard?(other) other.end_with?("?") end def respond "Sure." end end class << Shout = Object.new def heard?(other) other == other.upcase end def respond "Woah, chill out!" end end class << Default = Object.new def respond "Whatever." end end THOUGHTS = [Silent, Question, Shout] end