Class: TFLJourneyPlanner::Journey
- Inherits:
-
RecursiveOpenStruct
- Object
- RecursiveOpenStruct
- TFLJourneyPlanner::Journey
- Includes:
- TimeHelpers
- Defined in:
- lib/journey.rb
Instance Method Summary collapse
Methods included from TimeHelpers
Instance Method Details
#find_disruptions(options = {filter: :all}) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/journey.rb', line 30 def find_disruptions( = {filter: :all}) array = [] legs.each do |leg| leg.disruptions.each do |disruption| array << disruption.description if ([:filter] == :all || disruption.category.downcase == [:filter].to_s.downcase ) end end return array end |
#instructions ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/journey.rb', line 10 def instructions array = [] legs.each do |leg| if leg.instruction.steps.any? leg.instruction.steps.each {|step| array << [ "#{prettify leg.departure_time} - #{prettify leg.arrival_time}", step.description]} else array << ["#{prettify leg.departure_time} - #{prettify leg.arrival_time}", leg.instruction.summary + " / " + leg.instruction.detailed] end end array.inject(Hash.new{ |h,k| h[k]=[] }){ |h,(k,v)| h[k] << v; h } end |
#map_path ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/journey.rb', line 22 def map_path array = [] legs.each do |leg| array += JSON.parse(leg.path.line_string) end return array end |