Class: Time
- Inherits:
-
Object
- Object
- Time
- Defined in:
- lib/octocore-mongo/utils.rb
Instance Method Summary collapse
-
#ceil(height = 1) ⇒ Object
Find ceil time.
-
#floor(height = 1) ⇒ Object
Find floor time.
-
#to(to, step = 15.minutes) ⇒ Array<Time>
Finds the steps between two time.
Instance Method Details
#ceil(height = 1) ⇒ Object
Find ceil time
39 40 41 42 43 44 45 |
# File 'lib/octocore-mongo/utils.rb', line 39 def ceil(height = 1) if height < 1 height = 1 end sec = height.to_i * 60 Time.at((1 + (self.to_i / sec)).round * sec) end |
#floor(height = 1) ⇒ Object
Find floor time
29 30 31 32 33 34 35 |
# File 'lib/octocore-mongo/utils.rb', line 29 def floor(height = 1) if height < 1 height = 1 end sec = height.to_i * 60 Time.at((self.to_i / sec).round * sec) end |
#to(to, step = 15.minutes) ⇒ Array<Time>
Finds the steps between two time.
51 52 53 |
# File 'lib/octocore-mongo/utils.rb', line 51 def to(to, step = 15.minutes) [self].tap { |array| array << array.last + step while array.last < to } end |