Class: NJTransit::GTFS::Models::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/njtransit/gtfs/models/route.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Route

Returns a new instance of Route.



27
28
29
30
31
32
33
34
# File 'lib/njtransit/gtfs/models/route.rb', line 27

def initialize(attributes)
  @route_id = attributes[:route_id]
  @agency_id = attributes[:agency_id]
  @route_short_name = attributes[:route_short_name]
  @route_long_name = attributes[:route_long_name]
  @route_type = attributes[:route_type]
  @route_color = attributes[:route_color]
end

Class Attribute Details

.dbObject

Returns the value of attribute db.



8
9
10
# File 'lib/njtransit/gtfs/models/route.rb', line 8

def db
  @db
end

Instance Attribute Details

#agency_idObject (readonly)

Returns the value of attribute agency_id.



25
26
27
# File 'lib/njtransit/gtfs/models/route.rb', line 25

def agency_id
  @agency_id
end

#route_colorObject (readonly)

Returns the value of attribute route_color.



25
26
27
# File 'lib/njtransit/gtfs/models/route.rb', line 25

def route_color
  @route_color
end

#route_idObject (readonly)

Returns the value of attribute route_id.



25
26
27
# File 'lib/njtransit/gtfs/models/route.rb', line 25

def route_id
  @route_id
end

#route_long_nameObject (readonly)

Returns the value of attribute route_long_name.



25
26
27
# File 'lib/njtransit/gtfs/models/route.rb', line 25

def route_long_name
  @route_long_name
end

#route_short_nameObject (readonly)

Returns the value of attribute route_short_name.



25
26
27
# File 'lib/njtransit/gtfs/models/route.rb', line 25

def route_short_name
  @route_short_name
end

#route_typeObject (readonly)

Returns the value of attribute route_type.



25
26
27
# File 'lib/njtransit/gtfs/models/route.rb', line 25

def route_type
  @route_type
end

Class Method Details

.allObject



10
11
12
# File 'lib/njtransit/gtfs/models/route.rb', line 10

def all
  db[:routes].all.map { |row| new(row) }
end

.find(identifier) ⇒ Object



14
15
16
17
18
# File 'lib/njtransit/gtfs/models/route.rb', line 14

def find(identifier)
  row = db[:routes].where(route_id: identifier).first
  row ||= db[:routes].where(route_short_name: identifier).first
  row ? new(row) : nil
end

.where(conditions) ⇒ Object



20
21
22
# File 'lib/njtransit/gtfs/models/route.rb', line 20

def where(conditions)
  db[:routes].where(conditions).all.map { |row| new(row) }
end

Instance Method Details

#long_nameObject



40
41
42
# File 'lib/njtransit/gtfs/models/route.rb', line 40

def long_name
  route_long_name
end

#short_nameObject



36
37
38
# File 'lib/njtransit/gtfs/models/route.rb', line 36

def short_name
  route_short_name
end

#to_hObject



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/njtransit/gtfs/models/route.rb', line 44

def to_h
  {
    route_id: route_id,
    agency_id: agency_id,
    route_short_name: route_short_name,
    route_long_name: route_long_name,
    short_name: short_name,
    long_name: long_name,
    route_type: route_type,
    route_color: route_color
  }
end