Class: ZooStream::Event
- Inherits:
-
Object
- Object
- ZooStream::Event
- Defined in:
- lib/zoo_stream/event.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#linked ⇒ Object
readonly
Returns the value of attribute linked.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(source, type, data, linked, timestamp: Time.now) ⇒ Event
constructor
A new instance of Event.
- #to_h ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(source, type, data, linked, timestamp: Time.now) ⇒ Event
Returns a new instance of Event.
5 6 7 |
# File 'lib/zoo_stream/event.rb', line 5 def initialize(source, type, data, linked, timestamp: Time.now) @source, @type, @data, @linked, = source, type, data, linked, end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/zoo_stream/event.rb', line 3 def data @data end |
#linked ⇒ Object (readonly)
Returns the value of attribute linked.
3 4 5 |
# File 'lib/zoo_stream/event.rb', line 3 def linked @linked end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
3 4 5 |
# File 'lib/zoo_stream/event.rb', line 3 def source @source end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/zoo_stream/event.rb', line 3 def end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/zoo_stream/event.rb', line 3 def type @type end |
Instance Method Details
#to_h ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/zoo_stream/event.rb', line 9 def to_h { source: source, type: type, version: '1.0.0', timestamp: .utc.iso8601, data: data, linked: linked } end |
#to_json ⇒ Object
20 21 22 |
# File 'lib/zoo_stream/event.rb', line 20 def to_json to_h.to_json end |