Class: NationalRail::JourneyPlanner::TimeParser
- Inherits:
-
Object
- Object
- NationalRail::JourneyPlanner::TimeParser
- Defined in:
- lib/national-rail/journey_planner.rb
Instance Method Summary collapse
-
#initialize(date) ⇒ TimeParser
constructor
A new instance of TimeParser.
- #parse(hours_and_minutes) ⇒ Object
- #time(hours_and_minutes) ⇒ Object
Constructor Details
#initialize(date) ⇒ TimeParser
Returns a new instance of TimeParser.
78 79 80 81 |
# File 'lib/national-rail/journey_planner.rb', line 78 def initialize(date) @date = date @last_time = nil end |
Instance Method Details
#parse(hours_and_minutes) ⇒ Object
91 92 93 |
# File 'lib/national-rail/journey_planner.rb', line 91 def parse(hours_and_minutes) Time.zone.parse("#{hours_and_minutes} #{@date}") end |
#time(hours_and_minutes) ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'lib/national-rail/journey_planner.rb', line 82 def time(hours_and_minutes) time = parse(hours_and_minutes) if @last_time && (time < @last_time) @date += 1 time = parse(hours_and_minutes) end @last_time = time time end |