Class: Clock
- Inherits:
-
Time
- Object
- Time
- Clock
- Includes:
- Comparable
- Defined in:
- lib/clock.rb,
lib/MockAWS/clock.rb
Overview
Used to mock Time
Constant Summary collapse
- @@current_time =
0
Instance Attribute Summary collapse
-
#time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
- .at(time) ⇒ Object
- .hour ⇒ Object
- .now ⇒ Object
- .parse(tm) ⇒ Object
-
.reset ⇒ Object
testing.
- .set(numeric) ⇒ Object
- .sleep(numeric = 0) ⇒ Object
- .xmlschema(tm) ⇒ Object
Instance Method Summary collapse
- #+(time) ⇒ Object
- #-(clock) ⇒ Object
- #<=>(other) ⇒ Object
-
#initialize(time) ⇒ Clock
constructor
A new instance of Clock.
- #strftime(format) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(time) ⇒ Clock
Returns a new instance of Clock.
10 11 12 |
# File 'lib/MockAWS/clock.rb', line 10 def initialize(time) @time = time end |
Instance Attribute Details
#time ⇒ Object
Returns the value of attribute time.
5 6 7 |
# File 'lib/MockAWS/clock.rb', line 5 def time @time end |
Class Method Details
.at(time) ⇒ Object
14 15 16 |
# File 'lib/MockAWS/clock.rb', line 14 def Clock.at(time) Clock.new(time) end |
.hour ⇒ Object
22 23 24 |
# File 'lib/MockAWS/clock.rb', line 22 def Clock.hour (@@current_time/3600).floor end |
.now ⇒ Object
18 19 20 |
# File 'lib/MockAWS/clock.rb', line 18 def Clock.now Clock.new(@@current_time) end |
.parse(tm) ⇒ Object
54 55 56 |
# File 'lib/MockAWS/clock.rb', line 54 def Clock.parse(tm) Clock.new(Time.parse(tm).to_i) end |
.reset ⇒ Object
testing
60 61 62 |
# File 'lib/MockAWS/clock.rb', line 60 def Clock.reset @@current_time = 0 end |
.set(numeric) ⇒ Object
64 65 66 |
# File 'lib/MockAWS/clock.rb', line 64 def Clock.set(numeric) @@current_time = numeric end |
.sleep(numeric = 0) ⇒ Object
6 7 8 |
# File 'lib/clock.rb', line 6 def Clock.sleep(numeric = 0) Kernel.sleep numeric end |
Instance Method Details
#+(time) ⇒ Object
30 31 32 |
# File 'lib/MockAWS/clock.rb', line 30 def +(time) Clock.new(time + @time) end |
#-(clock) ⇒ Object
34 35 36 |
# File 'lib/MockAWS/clock.rb', line 34 def -(clock) @time - clock.time end |
#<=>(other) ⇒ Object
38 39 40 |
# File 'lib/MockAWS/clock.rb', line 38 def <=>(other) @time <=> other.time end |
#strftime(format) ⇒ Object
42 43 44 |
# File 'lib/MockAWS/clock.rb', line 42 def strftime(format) @time.to_s end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/MockAWS/clock.rb', line 26 def to_s @time.to_s end |