aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/chouette/connection_link_type.rb58
-rw-r--r--app/models/chouette/direction.rb77
2 files changed, 70 insertions, 65 deletions
diff --git a/app/models/chouette/connection_link_type.rb b/app/models/chouette/connection_link_type.rb
index ca27ed5da..ce05c3ec4 100644
--- a/app/models/chouette/connection_link_type.rb
+++ b/app/models/chouette/connection_link_type.rb
@@ -6,22 +6,6 @@ module Chouette
@numerical_code = numerical_code
end
- def self.new(text_code, numerical_code = nil)
- if text_code and numerical_code
- super
- elsif self === text_code
- text_code
- else
- if Fixnum === text_code
- text_code, numerical_code = definitions.rassoc(text_code)
- else
- text_code, numerical_code = definitions.assoc(text_code.to_s)
- end
-
- super text_code, numerical_code
- end
- end
-
def to_i
@numerical_code
end
@@ -34,19 +18,37 @@ module Chouette
camelize
end
- @@definitions = [
- ["underground", 0],
- ["mixed", 1],
- ["overground", 2]
- ]
- cattr_reader :definitions
-
- @@all = nil
- def self.all
- @@all ||= definitions.collect do |text_code, numerical_code|
- new(text_code, numerical_code)
+ class << self
+ attr_reader :definitions
+ @definitions = [
+ ["underground", 0],
+ ["mixed", 1],
+ ["overground", 2]
+ ]
+ @all = nil
+
+ def new(text_code, numerical_code = nil)
+ if text_code and numerical_code
+ super
+ elsif self === text_code
+ text_code
+ else
+ if Fixnum === text_code
+ text_code, numerical_code = definitions.rassoc(text_code)
+ else
+ text_code, numerical_code = definitions.assoc(text_code.to_s)
+ end
+
+ super text_code, numerical_code
+ end
end
- end
+ def all
+ @all ||= definitions.collect do |text_code, numerical_code|
+ new(text_code, numerical_code)
+ end
+ end
+
+ end
end
end \ No newline at end of file
diff --git a/app/models/chouette/direction.rb b/app/models/chouette/direction.rb
index 41d703b56..13d3b87ce 100644
--- a/app/models/chouette/direction.rb
+++ b/app/models/chouette/direction.rb
@@ -6,22 +6,6 @@ module Chouette
@numerical_code = numerical_code
end
- def self.new(text_code, numerical_code = nil)
- if text_code and numerical_code
- super
- elsif self === text_code
- text_code
- else
- if Fixnum === text_code
- text_code, numerical_code = definitions.rassoc(text_code)
- else
- text_code, numerical_code = definitions.assoc(text_code.to_s)
- end
-
- super text_code, numerical_code
- end
- end
-
def to_i
@numerical_code
end
@@ -34,28 +18,47 @@ module Chouette
to_s
end
- @@definitions = [
- ["straight_forward", 0],
- ["backward", 1],
- ["clock_wise", 2],
- ["counter_clock_wise", 3],
- ["north", 4],
- ["north_west", 5],
- ["west", 6],
- ["south_west", 7],
- ["south", 8],
- ["south_east", 9],
- ["east", 10],
- ["north_east", 11]
- ]
- cattr_reader :definitions
-
- @@all = nil
- def self.all
- @@all ||= definitions.collect do |text_code, numerical_code|
- new(text_code, numerical_code)
+ class << self
+
+ attr_reader :definitions
+ @definitions = [
+ ["straight_forward", 0],
+ ["backward", 1],
+ ["clock_wise", 2],
+ ["counter_clock_wise", 3],
+ ["north", 4],
+ ["north_west", 5],
+ ["west", 6],
+ ["south_west", 7],
+ ["south", 8],
+ ["south_east", 9],
+ ["east", 10],
+ ["north_east", 11]
+ ]
+ @all = nil
+
+ def new(text_code, numerical_code = nil)
+ if text_code and numerical_code
+ super
+ elsif self === text_code
+ text_code
+ else
+ if Fixnum === text_code
+ text_code, numerical_code = definitions.rassoc(text_code)
+ else
+ text_code, numerical_code = definitions.assoc(text_code.to_s)
+ end
+
+ super text_code, numerical_code
+ end
end
- end
+ def all
+ @all ||= definitions.collect do |text_code, numerical_code|
+ new(text_code, numerical_code)
+ end
+ end
+
+ end
end
end \ No newline at end of file