Class: TimePatterns::IntervalTimeEndingToken
- Inherits:
-
Object
- Object
- TimePatterns::IntervalTimeEndingToken
- Defined in:
- lib/todo_time_patterns/tokens.rb
Instance Attribute Summary collapse
-
#end_index ⇒ Object
readonly
Returns the value of attribute end_index.
-
#hours ⇒ Object
readonly
Returns the value of attribute hours.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#minutes ⇒ Object
readonly
Returns the value of attribute minutes.
-
#start_index ⇒ Object
readonly
Returns the value of attribute start_index.
Instance Method Summary collapse
-
#initialize(values) ⇒ IntervalTimeEndingToken
constructor
A new instance of IntervalTimeEndingToken.
- #set_start_and_end_indexes(values) ⇒ Object
- #set_time_and_interval(values) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(values) ⇒ IntervalTimeEndingToken
Returns a new instance of IntervalTimeEndingToken.
235 236 237 238 239 240 241 |
# File 'lib/todo_time_patterns/tokens.rb', line 235 def initialize(values) @values = values @values.extend(TokensStringRepresentation) set_start_and_end_indexes values set_time_and_interval values end |
Instance Attribute Details
#end_index ⇒ Object (readonly)
Returns the value of attribute end_index.
230 231 232 |
# File 'lib/todo_time_patterns/tokens.rb', line 230 def end_index @end_index end |
#hours ⇒ Object (readonly)
Returns the value of attribute hours.
232 233 234 |
# File 'lib/todo_time_patterns/tokens.rb', line 232 def hours @hours end |
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
233 234 235 |
# File 'lib/todo_time_patterns/tokens.rb', line 233 def interval @interval end |
#minutes ⇒ Object (readonly)
Returns the value of attribute minutes.
231 232 233 |
# File 'lib/todo_time_patterns/tokens.rb', line 231 def minutes @minutes end |
#start_index ⇒ Object (readonly)
Returns the value of attribute start_index.
229 230 231 |
# File 'lib/todo_time_patterns/tokens.rb', line 229 def start_index @start_index end |
Instance Method Details
#set_start_and_end_indexes(values) ⇒ Object
243 244 245 246 |
# File 'lib/todo_time_patterns/tokens.rb', line 243 def set_start_and_end_indexes(values) @start_index = values.first.start_index @end_index = values.last.end_index end |
#set_time_and_interval(values) ⇒ Object
248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/todo_time_patterns/tokens.rb', line 248 def set_time_and_interval(values) first_time = values[1] second_time = values[3] first_time_minutes = first_time.hours * 60 + first_time.minutes second_time_minutes = second_time.hours * 60 + second_time.minutes raise "Second time in interval is less than the first one" if first_time_minutes > second_time_minutes @hours = first_time.hours @minutes = first_time.minutes @interval = second_time_minutes - first_time_minutes end |
#to_s ⇒ Object
262 263 264 |
# File 'lib/todo_time_patterns/tokens.rb', line 262 def to_s "{ending_form}" end |