Class: Pie::Place
- Inherits:
-
Object
- Object
- Pie::Place
- Defined in:
- lib/place.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Instance Method Summary collapse
-
#initialize(places, options) ⇒ Place
constructor
A new instance of Place.
- #path(nodes) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(places, options) ⇒ Place
Returns a new instance of Place.
5 6 7 8 9 10 11 12 |
# File 'lib/place.rb', line 5 def initialize(places, ) @paths = {} @places = places () extract_name_and_description() @places[@name] = self end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/place.rb', line 3 def description @description end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/place.rb', line 3 def name @name end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
3 4 5 |
# File 'lib/place.rb', line 3 def paths @paths end |
Instance Method Details
#path(nodes) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/place.rb', line 18 def path(nodes) nodes.each do |place_name, direction| place = @places[place_name] raise "#{place_name} is not a place" if place.nil? @paths[place_name] = direction @places[place_name].paths[name] = direction.opposite unless !direction.respond_to?(:dead_end?) || direction.dead_end? end end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/place.rb', line 14 def to_s @name end |