Class: ProgressBar::Time

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-progressbar/time.rb

Class Method Summary collapse

Class Method Details

.now(time = ::Time) ⇒ Object



3
4
5
6
7
# File 'lib/ruby-progressbar/time.rb', line 3

def self.now(time = ::Time)
  @time = time

  @time.send unmocked_time_method
end

.time_mocking_library_methodsObject



17
18
19
20
21
22
23
# File 'lib/ruby-progressbar/time.rb', line 17

def self.time_mocking_library_methods
  [
    :now_without_mock_time,       # Timecop
    :now_without_delorean,        # Delorean
    :now                          # Actual
  ]
end

.unmocked_time_methodObject



9
10
11
12
13
14
15
# File 'lib/ruby-progressbar/time.rb', line 9

def self.unmocked_time_method
  @unmocked_time_method ||= begin
                              time_mocking_library_methods.find do |method|
                                @time.respond_to? method
                              end
                            end
end