Class: Runreg::Event
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Runreg::Event
- Defined in:
- lib/runreg/event.rb
Class Method Summary collapse
-
.convert_datetime(string) ⇒ Object
Date/times come in format /Date(1592625600000-0400)/.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(hash) ⇒ Event
Returns a new instance of Event.
5 6 7 8 9 10 11 12 13 |
# File 'lib/runreg/event.rb', line 5 def initialize hash hash.keys.each do |key| if key.match?(/Date/) && hash[key] hash[key] = Runreg::Event.convert_datetime(hash[key]) end end super hash end |
Class Method Details
.convert_datetime(string) ⇒ Object
Date/times come in format /Date(1592625600000-0400)/
16 17 18 |
# File 'lib/runreg/event.rb', line 16 def self.convert_datetime string DateTime.strptime(string, '/Date(%Q%z)/').to_s end |