Class: TimeRangeExtractor::MatchResult

Inherits:
Object
  • Object
show all
Defined in:
lib/time_range_extractor/match_result.rb

Instance Method Summary collapse

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_periodObject



27
28
29
# File 'lib/time_range_extractor/match_result.rb', line 27

def end_period
  match_data[:end_period]
end

#end_timeObject



23
24
25
# File 'lib/time_range_extractor/match_result.rb', line 23

def end_time
  match_data[:end_time]
end

#end_time_stringObject



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_periodObject



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_timeObject



13
14
15
# File 'lib/time_range_extractor/match_result.rb', line 13

def start_time
  match_data[:start_time]
end

#start_time_stringObject



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_zoneObject



31
32
33
# File 'lib/time_range_extractor/match_result.rb', line 31

def time_zone
  match_data[:time_zone]
end

#valid?Boolean

Returns:

  • (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