Class: NJTransit::GTFS::Models::Stop
- Inherits:
-
Object
- Object
- NJTransit::GTFS::Models::Stop
- Defined in:
- lib/njtransit/gtfs/models/stop.rb
Class Attribute Summary collapse
-
.db ⇒ Object
Returns the value of attribute db.
Instance Attribute Summary collapse
-
#stop_code ⇒ Object
readonly
Returns the value of attribute stop_code.
-
#stop_id ⇒ Object
readonly
Returns the value of attribute stop_id.
-
#stop_lat ⇒ Object
readonly
Returns the value of attribute stop_lat.
-
#stop_lon ⇒ Object
readonly
Returns the value of attribute stop_lon.
-
#stop_name ⇒ Object
readonly
Returns the value of attribute stop_name.
-
#zone_id ⇒ Object
readonly
Returns the value of attribute zone_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Stop
constructor
A new instance of Stop.
- #lat ⇒ Object
- #lon ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Stop
Returns a new instance of Stop.
31 32 33 34 35 36 37 38 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 31 def initialize(attributes) @stop_id = attributes[:stop_id] @stop_code = attributes[:stop_code] @stop_name = attributes[:stop_name] @stop_lat = attributes[:stop_lat] @stop_lon = attributes[:stop_lon] @zone_id = attributes[:zone_id] end |
Class Attribute Details
.db ⇒ Object
Returns the value of attribute db.
8 9 10 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 8 def db @db end |
Instance Attribute Details
#stop_code ⇒ Object (readonly)
Returns the value of attribute stop_code.
29 30 31 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 29 def stop_code @stop_code end |
#stop_id ⇒ Object (readonly)
Returns the value of attribute stop_id.
29 30 31 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 29 def stop_id @stop_id end |
#stop_lat ⇒ Object (readonly)
Returns the value of attribute stop_lat.
29 30 31 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 29 def stop_lat @stop_lat end |
#stop_lon ⇒ Object (readonly)
Returns the value of attribute stop_lon.
29 30 31 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 29 def stop_lon @stop_lon end |
#stop_name ⇒ Object (readonly)
Returns the value of attribute stop_name.
29 30 31 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 29 def stop_name @stop_name end |
#zone_id ⇒ Object (readonly)
Returns the value of attribute zone_id.
29 30 31 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 29 def zone_id @zone_id end |
Class Method Details
.all ⇒ Object
10 11 12 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 10 def all db[:stops].all.map { |row| new(row) } end |
.find(stop_id) ⇒ Object
14 15 16 17 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 14 def find(stop_id) row = db[:stops].where(stop_id: stop_id).first row ? new(row) : nil end |
.find_by_code(stop_code) ⇒ Object
19 20 21 22 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 19 def find_by_code(stop_code) row = db[:stops].where(stop_code: stop_code).first row ? new(row) : nil end |
.where(conditions) ⇒ Object
24 25 26 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 24 def where(conditions) db[:stops].where(conditions).all.map { |row| new(row) } end |
Instance Method Details
#lat ⇒ Object
40 41 42 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 40 def lat stop_lat end |
#lon ⇒ Object
44 45 46 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 44 def lon stop_lon end |
#to_h ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/njtransit/gtfs/models/stop.rb', line 48 def to_h { stop_id: stop_id, stop_code: stop_code, stop_name: stop_name, stop_lat: stop_lat, stop_lon: stop_lon, lat: lat, lon: lon, zone_id: zone_id } end |