blob: 4802d7592c37306bf4b8088c5e3896e64fbeab1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
module Chouette
class Network < Chouette::ActiveRecord
has_metadata
include NetworkRestrictions
include LineReferentialSupport
include ObjectidSupport
extend Enumerize
has_many :lines
attr_accessor :source_type_name
enumerize :source_type_name, in: %w(public_and_private_utilities
road_authorities
transit_operator
public_transport
passenger_transport_coordinating_authority
travel_information_service_provider
travel_agency
individual_subject_of_travel_itinerary
other_information)
validates_format_of :registration_number, :with => %r{\A[0-9A-Za-z_-]+\Z}, :allow_nil => true, :allow_blank => true
validates_presence_of :name
def self.object_id_key
"PTNetwork"
end
def self.nullable_attributes
[:source_name, :source_type, :source_identifier, :comment]
end
def commercial_stop_areas
Chouette::StopArea.joins(:children => [:stop_points => [:route => [:line => :network] ] ]).where(:networks => {:id => self.id}).uniq
end
def stop_areas
Chouette::StopArea.joins(:stop_points => [:route => [:line => :network] ]).where(:networks => {:id => self.id})
end
def source_type_name
# return nil if source_type is nil
source_type && Chouette::SourceType.new( source_type.underscore)
end
def source_type_name=(source_type_name)
self.source_type = (source_type_name ? source_type_name.camelcase : nil)
end
@@source_type_names = nil
def self.source_type_names
@@source_type_names ||= Chouette::SourceType.all.select do |source_type_name|
source_type_name.to_i > 0
end
end
end
end
|