Class: Ankit::Envelope

Inherits:
Struct
  • Object
show all
Defined in:
lib/ankit/event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#atObject

Returns the value of attribute at

Returns:

  • (Object)

    the current value of at



6
7
8
# File 'lib/ankit/event.rb', line 6

def at
  @at
end

#roundObject

Returns the value of attribute round

Returns:

  • (Object)

    the current value of 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