Class: NJTransit::GTFS::Models::Route
- Inherits:
-
Object
- Object
- NJTransit::GTFS::Models::Route
- Defined in:
- lib/njtransit/gtfs/models/route.rb
Class Attribute Summary collapse
-
.db ⇒ Object
Returns the value of attribute db.
Instance Attribute Summary collapse
-
#agency_id ⇒ Object
readonly
Returns the value of attribute agency_id.
-
#route_color ⇒ Object
readonly
Returns the value of attribute route_color.
-
#route_id ⇒ Object
readonly
Returns the value of attribute route_id.
-
#route_long_name ⇒ Object
readonly
Returns the value of attribute route_long_name.
-
#route_short_name ⇒ Object
readonly
Returns the value of attribute route_short_name.
-
#route_type ⇒ Object
readonly
Returns the value of attribute route_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Route
constructor
A new instance of Route.
- #long_name ⇒ Object
- #short_name ⇒ Object
- #to_h ⇒ Object
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
.db ⇒ Object
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_id ⇒ Object (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_color ⇒ Object (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_id ⇒ Object (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_name ⇒ Object (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_name ⇒ Object (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_type ⇒ Object (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
.all ⇒ Object
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_name ⇒ Object
40 41 42 |
# File 'lib/njtransit/gtfs/models/route.rb', line 40 def long_name route_long_name end |
#short_name ⇒ Object
36 37 38 |
# File 'lib/njtransit/gtfs/models/route.rb', line 36 def short_name route_short_name end |
#to_h ⇒ Object
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 |