Class: Mutx::Support::TimeHelper
- Inherits:
-
Object
- Object
- Mutx::Support::TimeHelper
- Defined in:
- lib/mutx/support/time_helper.rb
Class Method Summary collapse
- .elapsed ⇒ Object
-
.elapsed_from_last_check_greater_than?(seconds) ⇒ Boolean
Use start class method before using this class method.
- .formatted_time_for(timestamp) ⇒ Object
- .now ⇒ Object
- .now_in_seconds ⇒ Object
- .start ⇒ Object
- .wait_for(seconds) ⇒ Object
Class Method Details
.elapsed ⇒ Object
15 16 17 |
# File 'lib/mutx/support/time_helper.rb', line 15 def self.elapsed self.now_in_seconds - @@start end |
.elapsed_from_last_check_greater_than?(seconds) ⇒ Boolean
Use start class method before using this class method
20 21 22 23 24 25 26 27 28 |
# File 'lib/mutx/support/time_helper.rb', line 20 def self.elapsed_from_last_check_greater_than? seconds raise "seconds arg must be a Fixnum" unless seconds.is_a? Fixnum if (self.now_in_seconds - @@stamp) > seconds @@stamp = self.now_in_seconds true else false end end |
.formatted_time_for(timestamp) ⇒ Object
6 7 8 |
# File 'lib/mutx/support/time_helper.rb', line 6 def self.formatted_time_for Time.at().strftime(Mutx::Support::Configuration.formatted_datetime) end |
.now ⇒ Object
41 42 43 |
# File 'lib/mutx/support/time_helper.rb', line 41 def self.now Time.now end |
.now_in_seconds ⇒ Object
37 38 39 |
# File 'lib/mutx/support/time_helper.rb', line 37 def self.now_in_seconds self.now.to_i end |
.start ⇒ Object
10 11 12 13 |
# File 'lib/mutx/support/time_helper.rb', line 10 def self.start @@start = self.now_in_seconds @@stamp = self.now_in_seconds end |
.wait_for(seconds) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/mutx/support/time_helper.rb', line 30 def self.wait_for seconds self.start begin end until self.elapsed_from_last_check_greater_than? seconds seconds end |