Class: TimeRangeExtractor::MatchResult
- Inherits:
-
Object
- Object
- TimeRangeExtractor::MatchResult
- Defined in:
- lib/time_range_extractor/match_result.rb
Instance Method Summary collapse
- #end_period ⇒ Object
- #end_time ⇒ Object
- #end_time_string ⇒ Object
-
#initialize(match_data) ⇒ MatchResult
constructor
A new instance of MatchResult.
- #start_period ⇒ Object
- #start_time ⇒ Object
- #start_time_string ⇒ Object
- #time_zone ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(match_data) ⇒ MatchResult
Returns a new instance of MatchResult.
5 6 7 |
# File 'lib/time_range_extractor/match_result.rb', line 5 def initialize(match_data) @match_data = match_data end |
Instance Method Details
#end_period ⇒ Object
27 28 29 |
# File 'lib/time_range_extractor/match_result.rb', line 27 def end_period match_data[:end_period] end |
#end_time ⇒ Object
23 24 25 |
# File 'lib/time_range_extractor/match_result.rb', line 23 def end_time match_data[:end_time] end |
#end_time_string ⇒ Object
39 40 41 |
# File 'lib/time_range_extractor/match_result.rb', line 39 def end_time_string [end_time, end_period, time_zone].compact.join(' ') end |
#start_period ⇒ Object
17 18 19 20 21 |
# File 'lib/time_range_extractor/match_result.rb', line 17 def start_period @start_period ||= match_data[:start_period].presence || begin force_start_period_to_am? ? 'am' : end_period end end |
#start_time ⇒ Object
13 14 15 |
# File 'lib/time_range_extractor/match_result.rb', line 13 def start_time match_data[:start_time] end |
#start_time_string ⇒ Object
35 36 37 |
# File 'lib/time_range_extractor/match_result.rb', line 35 def start_time_string [start_time, start_period, time_zone].compact.join(' ') end |
#time_zone ⇒ Object
31 32 33 |
# File 'lib/time_range_extractor/match_result.rb', line 31 def time_zone match_data[:time_zone] end |
#valid? ⇒ Boolean
9 10 11 |
# File 'lib/time_range_extractor/match_result.rb', line 9 def valid? @match_data && (start_time.present? && end_time.present?) end |