Class: DucklingService::TimeOption
- Inherits:
-
Struct
- Object
- Struct
- DucklingService::TimeOption
- Defined in:
- src/services/duckling_service.rb
Overview
Model for an extracted time
The two main values are time
and grain
:
time
is the ruby Time object that was extracted.grain
is the specificity of the time. One ofyear
,month
,day
,hour
,minute
,second
.
Instance Attribute Summary collapse
-
#grain ⇒ 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'
The time grain.
-
#time ⇒ Time
The ruby Time object that was extracted.
Instance Method Summary collapse
-
#date_grain? ⇒ Boolean
Does this option have year/month/day specificity?.
-
#future? ⇒ Boolean
Is the parsed time in the future?.
-
#interval? ⇒ false
Is this an interval of values?.
-
#past? ⇒ Boolean
Is the parsed time in the past?.
-
#time_grain? ⇒ Boolean
Does this option have hour/minute/second specificity?.
-
#value? ⇒ true
Is this a single value, or an interval of values?.
Instance Attribute Details
#grain ⇒ 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'
Returns the time grain
139 140 141 |
# File 'src/services/duckling_service.rb', line 139 def grain @grain end |
#time ⇒ Time
Returns the ruby Time object that was extracted
139 140 141 |
# File 'src/services/duckling_service.rb', line 139 def time @time end |
Instance Method Details
#date_grain? ⇒ Boolean
Does this option have year/month/day specificity?
170 171 172 |
# File 'src/services/duckling_service.rb', line 170 def date_grain? ['year', 'month', 'day', 'date'].include? grain end |
#future? ⇒ Boolean
Is the parsed time in the future?
177 178 179 |
# File 'src/services/duckling_service.rb', line 177 def future? time.future? end |
#interval? ⇒ false
Is this an interval of values?
156 157 158 |
# File 'src/services/duckling_service.rb', line 156 def interval? false end |
#past? ⇒ Boolean
Is the parsed time in the past?
184 185 186 |
# File 'src/services/duckling_service.rb', line 184 def past? time.past? end |
#time_grain? ⇒ Boolean
Does this option have hour/minute/second specificity?
163 164 165 |
# File 'src/services/duckling_service.rb', line 163 def time_grain? ['hour', 'minute', 'second'].include? grain end |
#value? ⇒ true
Is this a single value, or an interval of values?
149 150 151 |
# File 'src/services/duckling_service.rb', line 149 def value? true end |