Class: Tarzan::Interfaces::Base::Interface

Inherits:
Object
  • Object
show all
Defined in:
lib/tarzan/interfaces/base/interface.rb

Direct Known Subclasses

Campfire::Interface, Shell::Interface

Instance Method Summary collapse

Instance Method Details

#playObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tarzan/interfaces/base/interface.rb', line 8

def play
  say %{Welcome to the Game Hall}

  say %{Pick [R]ockPaperScissors or [O]ddsAndEvens: }

  game = case prompt(['R', 'O'])
    when 'R' then Tarzan::Games::RockPaperScissors::Game.new interface: self
    when 'O' then Tarzan::Games::OddsAndEvens::Game.new interface: self
  end

  game.play

  say %{Goodbye, and come back to the Game Hall}
end

#prompt(valid_choices = []) ⇒ Object



27
28
29
# File 'lib/tarzan/interfaces/base/interface.rb', line 27

def prompt(valid_choices = [])
  # Subclasses are expected to define how to prompt messages
end

#say(message) ⇒ Object



23
24
25
# File 'lib/tarzan/interfaces/base/interface.rb', line 23

def say(message)
  # Subclasses are expected to define how to say messages
end