Class: Rubyquest::Map

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output = Output.new) ⇒ Map

Returns a new instance of Map.



8
9
10
# File 'lib/rubyquest/map.rb', line 8

def initialize(output = Output.new)
  @output = output
end

Instance Attribute Details

#currentObject

Returns the value of attribute current.



6
7
8
# File 'lib/rubyquest/map.rb', line 6

def current
  @current
end

#outputObject (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

#listObject



19
20
21
22
23
24
25
# File 'lib/rubyquest/map.rb', line 19

def list
  message = ""
  places.each_with_index do |place, i|
    message << "#{i + 1}. #{place.name}"
  end
  output.action message
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