Class: Pie::Place

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options)
  @paths = {}
  @places = places
  
  extract_standard_options(options)
  extract_name_and_description(options)
  @places[@name] = self
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/place.rb', line 3

def description
  @description
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/place.rb', line 3

def name
  @name
end

#pathsObject (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_sObject



14
15
16
# File 'lib/place.rb', line 14

def to_s
  @name
end