Class: CTA::BusTracker::Pattern
- Inherits:
-
Object
- Object
- CTA::BusTracker::Pattern
- Defined in:
- lib/cta_redux/api/bus_tracker.rb
Overview
Pattern objects enclose Point objects that describe a bus route. Conceptually it is similar to how a Trip contains many StopTime objects that describe the route a vehicle takes. However, it is specific to busses and contains better information for drawing turns and side-streets that the bus may take on its route. This bit of the API is mostly unnecessary unless you’re drawing maps.
Instance Attribute Summary collapse
-
#direction ⇒ Direction
readonly
A Direction object that describes to which direction of a route this pattern applies.
-
#id ⇒ Integer
readonly
The ID of the pattern.
-
#length ⇒ Integer
readonly
The total length of the pattern.
-
#pattern_id ⇒ Integer
readonly
The ID of the pattern.
- #points ⇒ Array<Point> readonly
Instance Method Summary collapse
-
#initialize(p) ⇒ Pattern
constructor
A new instance of Pattern.
Constructor Details
#initialize(p) ⇒ Pattern
Returns a new instance of Pattern.
190 191 192 193 194 195 196 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 190 def initialize(p) @id = @pattern_id = p["pid"].to_i @length = p["ln"].to_f @direction = Direction.new(p["rtdir"]) @points = Array.wrap(p["pt"]).map { |pnt| Point.new(pnt) } end |
Instance Attribute Details
#direction ⇒ Direction (readonly)
This logically means that any given bus route (so long as it’s not a circulator or one-way express) will have two associated CTA::BusTracker::Pattern objects
Returns A Direction object that describes to which direction of a route this pattern applies.
186 187 188 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 186 def direction @direction end |
#id ⇒ Integer (readonly)
Returns The ID of the pattern.
178 179 180 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 178 def id @id end |
#length ⇒ Integer (readonly)
Returns The total length of the pattern.
182 183 184 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 182 def length @length end |
#pattern_id ⇒ Integer (readonly)
Returns The ID of the pattern.
180 181 182 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 180 def pattern_id @pattern_id end |
#points ⇒ Array<Point> (readonly)
Returns An array of CTA::BusTracker::Point objects that describe stops and waypoints along the CTA::BusTracker::Pattern.
188 189 190 |
# File 'lib/cta_redux/api/bus_tracker.rb', line 188 def points @points end |