Class: Range
- Inherits:
-
Object
- Object
- Range
- Defined in:
- lib/timemaster/extensions.rb
Instance Method Summary collapse
-
#to_days ⇒ Object
Takes a range and converts it to an array of days.
-
#to_hours ⇒ Object
Takes a range and converts it to an array of hours.
-
#to_minutes ⇒ Object
Takes a range and converts it to an array of minutes.
-
#to_months ⇒ Object
Takes a range and converts it to an array of months.
Instance Method Details
#to_days ⇒ Object
Takes a range and converts it to an array of days
(Time.now..7.days.from_now).to_days
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/timemaster/extensions.rb', line 42 def to_days return if first > last arr = [] time = first while time <= last arr << time time += 1.day end return arr end |
#to_hours ⇒ Object
Takes a range and converts it to an array of hours
(Time.now..1.day.from_now).to_hours
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/timemaster/extensions.rb', line 58 def to_hours return if first > last arr = [] time = first while time <= last arr << time time += 1.hour end return arr end |
#to_minutes ⇒ Object
Takes a range and converts it to an array of minutes
(Time.now..1.day.from_now).to_hours
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/timemaster/extensions.rb', line 74 def to_minutes return if first > last arr = [] time = first while time <= last arr << time time += 1.minute end return arr end |
#to_months ⇒ Object
Takes a range and converts it to an array of months
(Time.now..1.day.from_now).to_hours
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/timemaster/extensions.rb', line 27 def to_months return if first > last arr = [] time = first while time <= last arr << time time += 1.month end return arr end |