Class: Runreg::Event

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/runreg/event.rb

Class Method Summary collapse

Instance Method Summary collapse

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