Class: ZooStream::Event

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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, @timestamp = source, type, data, linked, timestamp
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/zoo_stream/event.rb', line 3

def data
  @data
end

#linkedObject (readonly)

Returns the value of attribute linked.



3
4
5
# File 'lib/zoo_stream/event.rb', line 3

def linked
  @linked
end

#sourceObject (readonly)

Returns the value of attribute source.



3
4
5
# File 'lib/zoo_stream/event.rb', line 3

def source
  @source
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



3
4
5
# File 'lib/zoo_stream/event.rb', line 3

def timestamp
  @timestamp
end

#typeObject (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_hObject



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: timestamp.utc.iso8601,
    data: data,
    linked: linked
  }
end

#to_jsonObject



20
21
22
# File 'lib/zoo_stream/event.rb', line 20

def to_json
  to_h.to_json
end