Class: TextPlayer::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/text_player/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/text_player/cli.rb', line 25

def self.exit_on_failure?
  true
end

Instance Method Details

#play(game) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/text_player/cli.rb', line 12

def play(game)
  gamefile = TextPlayer::Gamefile.from_input(game)
  session = TextPlayer::Session.new(gamefile)

  formatter_type = options[:formatter].downcase.to_sym
  formatter = TextPlayer::Formatters.by_name(formatter_type)

  session.run do |result|
    formatter.write(result, $stdout)
    $stdin.gets
  end
end