Class: CTA::BusTracker::Pattern

Inherits:
Object
  • Object
show all
Defined in:
lib/cta_redux/api/bus_tracker.rb

Overview

Note:

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

Instance Method Summary collapse

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

#directionDirection (readonly)

Note:

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.

Returns:

  • (Direction)

    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

#idInteger (readonly)

Returns The ID of the pattern.

Returns:

  • (Integer)

    The ID of the pattern



178
179
180
# File 'lib/cta_redux/api/bus_tracker.rb', line 178

def id
  @id
end

#lengthInteger (readonly)

Returns The total length of the pattern.

Returns:

  • (Integer)

    The total length of the pattern



182
183
184
# File 'lib/cta_redux/api/bus_tracker.rb', line 182

def length
  @length
end

#pattern_idInteger (readonly)

Returns The ID of the pattern.

Returns:

  • (Integer)

    The ID of the pattern



180
181
182
# File 'lib/cta_redux/api/bus_tracker.rb', line 180

def pattern_id
  @pattern_id
end

#pointsArray<Point> (readonly)

Returns An array of CTA::BusTracker::Point objects that describe stops and waypoints along the CTA::BusTracker::Pattern.

Returns:



188
189
190
# File 'lib/cta_redux/api/bus_tracker.rb', line 188

def points
  @points
end