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
12 13 14 |
# File 'lib/quandl/operation/core_ext/time.rb', line 12 def elapsed( = nil, &block) log_elapsed(, &block) end |
Instance Method Details
#elapsed ⇒ Object
52 53 54 |
# File 'lib/quandl/operation/core_ext/time.rb', line 52 def elapsed elapsed_since(Time.now) end |
#elapsed_ms ⇒ Object
60 61 62 |
# File 'lib/quandl/operation/core_ext/time.rb', line 60 def elapsed_ms "#{elapsed.microseconds}ms" end |
#elapsed_since(time) ⇒ Object
56 57 58 |
# File 'lib/quandl/operation/core_ext/time.rb', line 56 def elapsed_since(time) time - self end |
#floor(seconds = 60) ⇒ Object
37 38 39 |
# File 'lib/quandl/operation/core_ext/time.rb', line 37 def floor(seconds = 60) Time.at((to_f / seconds).floor * seconds) end |
#microseconds ⇒ Object
41 42 43 |
# File 'lib/quandl/operation/core_ext/time.rb', line 41 def microseconds (to_f * 1000.0).to_i end |
#month_from_beginning_to_end ⇒ Object
25 26 27 |
# File 'lib/quandl/operation/core_ext/time.rb', line 25 def month_from_beginning_to_end (beginning_of_month..end_of_month) end |
#round(seconds = 60) ⇒ Object
33 34 35 |
# File 'lib/quandl/operation/core_ext/time.rb', line 33 def round(seconds = 60) Time.at((to_f / seconds).round * seconds) end |
#this_month? ⇒ Boolean
29 30 31 |
# File 'lib/quandl/operation/core_ext/time.rb', line 29 def this_month? month_from_beginning_to_end.cover?(Time.now) end |
#this_week? ⇒ Boolean
21 22 23 |
# File 'lib/quandl/operation/core_ext/time.rb', line 21 def this_week? week_from_beginning_to_end.cover?(Time.now) end |
#week_from_beginning_to_end ⇒ Object
17 18 19 |
# File 'lib/quandl/operation/core_ext/time.rb', line 17 def week_from_beginning_to_end (beginning_of_week..end_of_week) end |