Class: Rubyquest::Map
- Inherits:
-
Object
- Object
- Rubyquest::Map
- Defined in:
- lib/rubyquest/map.rb
Instance Attribute Summary collapse
-
#current ⇒ Object
readonly
Returns the value of attribute current.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
- #add(place) ⇒ Object
-
#initialize(output = Output.new) ⇒ Map
constructor
A new instance of Map.
- #list ⇒ Object
- #travel(place) ⇒ Object
Constructor Details
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current.
6 7 8 |
# File 'lib/rubyquest/map.rb', line 6 def current @current end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
6 7 8 |
# File 'lib/rubyquest/map.rb', line 6 def output @output end |
Instance Method Details
#add(place) ⇒ Object
27 28 29 |
# File 'lib/rubyquest/map.rb', line 27 def add place places.push place end |
#list ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/rubyquest/map.rb', line 19 def list = "" places.each_with_index do |place, i| << "#{i + 1}. #{place.name}" end output.action end |
#travel(place) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/rubyquest/map.rb', line 12 def travel place #if Place.find(place) self.current = place #else #output.error "#{place} is not a valid place. Type 'map' to list all available places" end |