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

Version Path
trackler-2.2.1.180 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.179 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.178 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.177 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.176 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.175 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.174 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.173 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.172 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.171 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.170 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.169 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.167 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.166 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.165 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.164 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.163 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.162 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.161 tracks/ruby/exercises/bob/.meta/solutions/bob.rb
trackler-2.2.1.160 tracks/ruby/exercises/bob/.meta/solutions/bob.rb