Class: ProgressBar::Time
- Inherits:
-
Object
- Object
- ProgressBar::Time
- Defined in:
- lib/ruby-progressbar/time.rb
Constant Summary collapse
- TIME_MOCKING_LIBRARY_METHODS =
[ :__simple_stub__now, # ActiveSupport :now_without_mock_time, # Timecop :now_without_delorean, # Delorean :now # Actual ].freeze
Instance Method Summary collapse
-
#initialize(time = ::Time) ⇒ Time
constructor
A new instance of Time.
- #now ⇒ Object
- #unmocked_time_method ⇒ Object
Constructor Details
#initialize(time = ::Time) ⇒ Time
Returns a new instance of Time.
10 11 12 |
# File 'lib/ruby-progressbar/time.rb', line 10 def initialize(time = ::Time) self.time = time end |
Instance Method Details
#now ⇒ Object
14 15 16 |
# File 'lib/ruby-progressbar/time.rb', line 14 def now time.__send__ unmocked_time_method end |
#unmocked_time_method ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/ruby-progressbar/time.rb', line 18 def unmocked_time_method @unmocked_time_method ||= begin TIME_MOCKING_LIBRARY_METHODS.find do |method| time.respond_to? method end end end |