Class: Downtime::Timestamp
- Inherits:
-
Object
- Object
- Downtime::Timestamp
- Defined in:
- lib/downtime/timestamp.rb
Constant Summary collapse
- @@time_pattern =
"%Y-%m-%d-%H-%M"- @@time_pattern_zone =
"%Y-%m-%d-%H-%M %Z"
Instance Attribute Summary collapse
-
#datetime ⇒ Object
Returns the value of attribute datetime.
Class Method Summary collapse
-
.from_s(string) ⇒ Object
Will create CET times.
- .time_pattern ⇒ Object
Instance Method Summary collapse
-
#-(other_timestamp) ⇒ Object
Returns difference to other timestamp in minutes.
-
#initialize(time = DateTime.now) ⇒ Timestamp
constructor
A new instance of Timestamp.
- #to_s ⇒ Object
Constructor Details
#initialize(time = DateTime.now) ⇒ Timestamp
Returns a new instance of Timestamp.
13 14 15 |
# File 'lib/downtime/timestamp.rb', line 13 def initialize time=DateTime.now @datetime = time end |
Instance Attribute Details
#datetime ⇒ Object
Returns the value of attribute datetime.
7 8 9 |
# File 'lib/downtime/timestamp.rb', line 7 def datetime @datetime end |
Class Method Details
.from_s(string) ⇒ Object
Will create CET times.
22 23 24 |
# File 'lib/downtime/timestamp.rb', line 22 def self.from_s string Timestamp.new(DateTime.strptime string + " CET", @@time_pattern_zone) end |
.time_pattern ⇒ Object
9 10 11 |
# File 'lib/downtime/timestamp.rb', line 9 def self.time_pattern @@time_pattern end |
Instance Method Details
#-(other_timestamp) ⇒ Object
Returns difference to other timestamp in minutes.
27 28 29 |
# File 'lib/downtime/timestamp.rb', line 27 def -() ((@datetime.to_time - .datetime.to_time) / 60.0).to_i end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/downtime/timestamp.rb', line 17 def to_s @datetime.strftime @@time_pattern end |