Class: Rubyquest::CLI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input = ::Readline, output = Output) ⇒ CLI

Returns a new instance of CLI.



11
12
13
# File 'lib/rubyquest/cli.rb', line 11

def initialize input = ::Readline, output = Output
  @input, @output = input, output
end

Instance Attribute Details

#heroObject (readonly)

Returns the value of attribute hero.



9
10
11
# File 'lib/rubyquest/cli.rb', line 9

def hero
  @hero
end

#inputObject (readonly)

Returns the value of attribute input.



9
10
11
# File 'lib/rubyquest/cli.rb', line 9

def input
  @input
end

#outputObject (readonly)

Returns the value of attribute output.



9
10
11
# File 'lib/rubyquest/cli.rb', line 9

def output
  @output
end

Instance Method Details

#start!Object



15
16
17
18
19
20
21
# File 'lib/rubyquest/cli.rb', line 15

def start!
  greetings
  # Leave the game without a Ruby exception upon interruption
  trap(:INT) { puts; exit }
  set_user
  console
end