Class: Chouette::SourceType
- Inherits:
-
ActiveSupport::StringInquirer
- Object
- ActiveSupport::StringInquirer
- Chouette::SourceType
- Defined in:
- app/models/chouette/source_type.rb
Constant Summary collapse
- @@definitions =
[ ["public_and_private_utilities", 0], ["road_authorities", 1], ["transit_operator", 2], ["public_transport", 3], ["passenger_transport_coordinating_authority", 4], ["travel_information_service_provider", 5], ["travel_agency", 6], ["individual_subject_of_travel_itinerary", 7], ["other_information", 8] ]
- @@all =
nil
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(text_code, numerical_code) ⇒ SourceType
constructor
A new instance of SourceType.
- #inspect ⇒ Object
- #name ⇒ Object
- #to_i ⇒ Object
Constructor Details
#initialize(text_code, numerical_code) ⇒ SourceType
Returns a new instance of SourceType.
3 4 5 6 |
# File 'app/models/chouette/source_type.rb', line 3 def initialize(text_code, numerical_code) super text_code.to_s @numerical_code = numerical_code end |
Class Method Details
.all ⇒ Object
50 51 52 53 54 |
# File 'app/models/chouette/source_type.rb', line 50 def self.all @@all ||= definitions.collect do |text_code, numerical_code| new(text_code, numerical_code) end end |
.new(text_code, numerical_code = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/chouette/source_type.rb', line 8 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 |
Instance Method Details
#inspect ⇒ Object
28 29 30 |
# File 'app/models/chouette/source_type.rb', line 28 def inspect "#{to_s}/#{to_i}" end |
#name ⇒ Object
32 33 34 |
# File 'app/models/chouette/source_type.rb', line 32 def name camelize end |
#to_i ⇒ Object
24 25 26 |
# File 'app/models/chouette/source_type.rb', line 24 def to_i @numerical_code end |