aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/chouette/direction.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/chouette/direction.rb')
-rw-r--r--app/models/chouette/direction.rb99
1 files changed, 50 insertions, 49 deletions
diff --git a/app/models/chouette/direction.rb b/app/models/chouette/direction.rb
index 93bc1318b..41d703b56 100644
--- a/app/models/chouette/direction.rb
+++ b/app/models/chouette/direction.rb
@@ -1,60 +1,61 @@
-class Chouette::Direction < ActiveSupport::StringInquirer
+module Chouette
+ class Direction < ActiveSupport::StringInquirer
- def initialize(text_code, numerical_code)
- super text_code.to_s
- @numerical_code = numerical_code
- end
+ def initialize(text_code, numerical_code)
+ super text_code.to_s
+ @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)
+ def self.new(text_code, numerical_code = nil)
+ if text_code and numerical_code
+ super
+ elsif self === text_code
+ text_code
else
- text_code, numerical_code = definitions.assoc(text_code.to_s)
- end
+ 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
+ super text_code, numerical_code
+ end
end
- end
-
- def to_i
- @numerical_code
- end
- def inspect
- "#{to_s}/#{to_i}"
- end
+ def to_i
+ @numerical_code
+ end
- def name
- to_s
- end
+ def inspect
+ "#{to_s}/#{to_i}"
+ 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)
+ def name
+ to_s
end
- end
-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)
+ end
+ end
+ end
+end \ No newline at end of file