Class: Time
- Inherits:
-
Object
- Object
- Time
- Defined in:
- lib/quandl/operation/core_ext/time.rb
Class Method Summary collapse
Instance Method Summary collapse
- #elapsed ⇒ Object
- #elapsed_ms ⇒ Object
- #elapsed_since(time) ⇒ Object
- #floor(seconds = 60) ⇒ Object
- #microseconds ⇒ Object
- #month_from_beginning_to_end ⇒ Object
- #round(seconds = 60) ⇒ Object
- #this_month? ⇒ Boolean
- #this_week? ⇒ Boolean
- #week_from_beginning_to_end ⇒ Object
Class Method Details
.elapsed(message = nil, &block) ⇒ Object
14 15 16 |
# File 'lib/quandl/operation/core_ext/time.rb', line 14 def elapsed(=nil, &block) log_elapsed(, &block) end |
Instance Method Details
#elapsed ⇒ Object
53 54 55 |
# File 'lib/quandl/operation/core_ext/time.rb', line 53 def elapsed elapsed_since(Time.now) end |
#elapsed_ms ⇒ Object
61 62 63 |
# File 'lib/quandl/operation/core_ext/time.rb', line 61 def elapsed_ms "#{elapsed.microseconds}ms" end |
#elapsed_since(time) ⇒ Object
57 58 59 |
# File 'lib/quandl/operation/core_ext/time.rb', line 57 def elapsed_since(time) time - self end |
#floor(seconds = 60) ⇒ Object
38 39 40 |
# File 'lib/quandl/operation/core_ext/time.rb', line 38 def floor(seconds = 60) Time.at((self.to_f / seconds).floor * seconds) end |
#microseconds ⇒ Object
42 43 44 |
# File 'lib/quandl/operation/core_ext/time.rb', line 42 def microseconds (self.to_f * 1000.0).to_i end |
#month_from_beginning_to_end ⇒ Object
27 28 29 |
# File 'lib/quandl/operation/core_ext/time.rb', line 27 def month_from_beginning_to_end (self.beginning_of_month .. self.end_of_month) end |
#round(seconds = 60) ⇒ Object
34 35 36 |
# File 'lib/quandl/operation/core_ext/time.rb', line 34 def round(seconds = 60) Time.at((self.to_f / seconds).round * seconds) end |
#this_month? ⇒ Boolean
30 31 32 |
# File 'lib/quandl/operation/core_ext/time.rb', line 30 def this_month? self.month_from_beginning_to_end.cover?(Time.now) end |
#this_week? ⇒ Boolean
23 24 25 |
# File 'lib/quandl/operation/core_ext/time.rb', line 23 def this_week? self.week_from_beginning_to_end.cover?(Time.now) end |
#week_from_beginning_to_end ⇒ Object
20 21 22 |
# File 'lib/quandl/operation/core_ext/time.rb', line 20 def week_from_beginning_to_end (self.beginning_of_week .. self.end_of_week) end |