Class: Ankit::Envelope
- Inherits:
-
Struct
- Object
- Struct
- Ankit::Envelope
- Defined in:
- lib/ankit/event.rb
Instance Attribute Summary collapse
-
#at ⇒ Object
Returns the value of attribute at.
-
#round ⇒ Object
Returns the value of attribute round.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#at ⇒ Object
Returns the value of attribute at
6 7 8 |
# File 'lib/ankit/event.rb', line 6 def at @at end |
#round ⇒ Object
Returns the value of attribute round
6 7 8 |
# File 'lib/ankit/event.rb', line 6 def round @round end |
Class Method Details
.fresh(round = 0) ⇒ Object
16 |
# File 'lib/ankit/event.rb', line 16 def self.fresh(round=0); self.new(DateTime.new, round); end |
.from_hash(hash) ⇒ Object
11 12 13 |
# File 'lib/ankit/event.rb', line 11 def self.from_hash(hash) Envelope.new(DateTime.rfc3339(hash["at"]), hash["round"]) end |
.parse(text) ⇒ Object
15 |
# File 'lib/ankit/event.rb', line 15 def self.parse(text) from_hash(JSON.parse(text)); end |
Instance Method Details
#to_json(*a) ⇒ Object
7 8 9 |
# File 'lib/ankit/event.rb', line 7 def to_json(*a) { at: self.at.rfc3339, round: self.round }.to_json(*a) end |