Class: Chronic::RepeaterMinute
- Defined in:
- lib/chronic/repeaters/repeater_minute.rb
Overview
:nodoc:
Constant Summary collapse
- MINUTE_SECONDS =
60
Instance Attribute Summary
Attributes inherited from Tag
Instance Method Summary collapse
-
#initialize(type) ⇒ RepeaterMinute
constructor
A new instance of RepeaterMinute.
- #next(pointer = :future) ⇒ Object
- #offset(span, amount, pointer) ⇒ Object
- #this(pointer = :future) ⇒ Object
- #to_s ⇒ Object
- #width ⇒ Object
Methods inherited from Repeater
#<=>, scan, scan_for_day_names, scan_for_day_portions, scan_for_month_names, scan_for_season_names, scan_for_times, scan_for_units
Methods inherited from Tag
Constructor Details
#initialize(type) ⇒ RepeaterMinute
Returns a new instance of RepeaterMinute.
4 5 6 7 |
# File 'lib/chronic/repeaters/repeater_minute.rb', line 4 def initialize(type) super @current_minute_start = nil end |
Instance Method Details
#next(pointer = :future) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/chronic/repeaters/repeater_minute.rb', line 9 def next(pointer = :future) super if !@current_minute_start case pointer when :future @current_minute_start = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min + 1) when :past @current_minute_start = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min - 1) end else direction = pointer == :future ? 1 : -1 @current_minute_start += direction * MINUTE_SECONDS end Chronic::Span.new(@current_minute_start, @current_minute_start + MINUTE_SECONDS) end |
#offset(span, amount, pointer) ⇒ Object
45 46 47 48 |
# File 'lib/chronic/repeaters/repeater_minute.rb', line 45 def offset(span, amount, pointer) direction = pointer == :future ? 1 : -1 span + direction * amount * MINUTE_SECONDS end |
#this(pointer = :future) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/chronic/repeaters/repeater_minute.rb', line 27 def this(pointer = :future) super case pointer when :future minute_begin = @now minute_end = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min) when :past minute_begin = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min) minute_end = @now when :none minute_begin = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min) minute_end = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min) + MINUTE_SECONDS end Chronic::Span.new(minute_begin, minute_end) end |
#to_s ⇒ Object
54 55 56 |
# File 'lib/chronic/repeaters/repeater_minute.rb', line 54 def to_s super << '-minute' end |
#width ⇒ Object
50 51 52 |
# File 'lib/chronic/repeaters/repeater_minute.rb', line 50 def width MINUTE_SECONDS end |