Class: Aggro::Message::Events
- Inherits:
-
Struct
- Object
- Struct
- Aggro::Message::Events
- Defined in:
- lib/aggro/message/events.rb
Overview
Public: Get events message.
Constant Summary collapse
- TYPE_CODE =
'10'.freeze
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
-
#id ⇒ Object
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events
4 5 6 |
# File 'lib/aggro/message/events.rb', line 4 def events @events end |
#id ⇒ Object
Returns the value of attribute id
4 5 6 |
# File 'lib/aggro/message/events.rb', line 4 def id @id end |
Class Method Details
.parse(string) ⇒ Object
7 8 9 |
# File 'lib/aggro/message/events.rb', line 7 def self.parse(string) new string[2..37], parse_events(string[38..-1]) end |
.parse_events(string) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/aggro/message/events.rb', line 11 def self.parse_events(string) Enumerator.new do |yielder| MarshalStream.new(StringIO.new(string)).each do |raw_event| yielder << EventSerializer.deserialize(raw_event) end end end |
Instance Method Details
#serialize_events ⇒ Object
19 20 21 |
# File 'lib/aggro/message/events.rb', line 19 def serialize_events events.map { |event| Marshal.dump EventSerializer.serialize event }.join end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/aggro/message/events.rb', line 23 def to_s "#{TYPE_CODE}#{id}#{serialize_events}" end |