Sha256: 156414fde883ec2ec0012fa17a8947b6390259512d431d52f296f2c4427510ff
Contents?: true
Size: 680 Bytes
Versions: 32
Compression:
Stored size: 680 Bytes
Contents
module BookKeeping VERSION = 2 end module Bob def hey(drivel) answer Phrase.new(drivel) end def answer(phrase) case when phrase.silent? 'Fine. Be that way!' when phrase.loud? && phrase.quizzical? 'Calm down, I know what I\'m doing!' when phrase.loud? 'Whoa, chill out!' when phrase.quizzical? 'Sure.' else 'Whatever.' end end end class Phrase attr_reader :source def initialize(drivel) @source = drivel.to_s.strip end def quizzical? source.end_with?('?') end def loud? source =~ /[A-Z]/ && source.upcase == source end def silent? source.empty? end end Bob.extend Bob
Version data entries
32 entries across 32 versions & 1 rubygems