pie 0.2.4 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pie.rb +13 -4
- data/lib/place.rb +1 -16
- metadata +2 -2
data/lib/pie.rb
CHANGED
@@ -29,6 +29,10 @@ module Pie
|
|
29
29
|
}
|
30
30
|
@values[@language || :english][id]
|
31
31
|
end
|
32
|
+
|
33
|
+
def self.places
|
34
|
+
Pie[:places] ||= {}
|
35
|
+
end
|
32
36
|
|
33
37
|
def template(name = nil)
|
34
38
|
if name
|
@@ -47,12 +51,17 @@ module Pie
|
|
47
51
|
end
|
48
52
|
|
49
53
|
def place(options)
|
50
|
-
Place.new(options)
|
54
|
+
new_place = Place.new(options)
|
55
|
+
name = new_place.name
|
56
|
+
self.instance_eval %{
|
57
|
+
def #{name}
|
58
|
+
places[:#{name}]
|
59
|
+
end
|
60
|
+
}
|
61
|
+
places[new_place.name] = new_place
|
51
62
|
end
|
52
63
|
|
53
64
|
def current_place(name=nil)
|
54
|
-
puts "current_place"
|
55
|
-
puts places.inspect
|
56
65
|
if name
|
57
66
|
Pie[:current_place] = places[name.to_sym]
|
58
67
|
else
|
@@ -65,7 +74,7 @@ module Pie
|
|
65
74
|
end
|
66
75
|
|
67
76
|
def places
|
68
|
-
Pie
|
77
|
+
Pie.places
|
69
78
|
end
|
70
79
|
|
71
80
|
def language(language)
|
data/lib/place.rb
CHANGED
@@ -6,8 +6,6 @@ class Pie::Place
|
|
6
6
|
@paths = {}
|
7
7
|
extract_standard_options(options)
|
8
8
|
extract_name_and_description(options)
|
9
|
-
build_place_method
|
10
|
-
register_place
|
11
9
|
end
|
12
10
|
|
13
11
|
def to_s
|
@@ -17,7 +15,7 @@ class Pie::Place
|
|
17
15
|
def path(nodes)
|
18
16
|
nodes.each do |place_name, direction|
|
19
17
|
paths[place_name] = direction
|
20
|
-
places[place_name].paths[name] = direction.opposite unless !direction.respond_to?(:dead_end?) || direction.dead_end?
|
18
|
+
Pie.places[place_name].paths[name] = direction.opposite unless !direction.respond_to?(:dead_end?) || direction.dead_end?
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
@@ -31,17 +29,4 @@ class Pie::Place
|
|
31
29
|
|
32
30
|
def extract_standard_options(options)
|
33
31
|
end
|
34
|
-
|
35
|
-
def build_place_method
|
36
|
-
Pie.module_eval %{
|
37
|
-
def #{name}
|
38
|
-
Pie[:places][:#{name}]
|
39
|
-
end
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
def register_place
|
44
|
-
Pie[:places][name] = self
|
45
|
-
end
|
46
|
-
|
47
32
|
end
|