Class: Rubyquest::Command

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

Constant Summary collapse

COMMANDS =
[
 'go to <place>',
 'help',
 'exit'
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, hero = nil) ⇒ Command

Returns a new instance of Command.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rubyquest/command.rb', line 15

def initialize string, hero = nil
  case string
  when /^help$/
    help
  when /^exit$/
    nil
  when /^quests$/
    Quest.load
  when /^go to (\D*)$/
    $1
    go $1, hero.map
  else
    invalid string
  end
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



7
8
9
# File 'lib/rubyquest/command.rb', line 7

def output
  @output
end