Class: Lwes::Event
- Inherits:
-
Object
- Object
- Lwes::Event
- Defined in:
- lib/lwes/event.rb
Overview
Represent a LWES event, can read from and write to IO objects
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
-
.read(io) ⇒ Lwes::Event
Read from an IO object.
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Event
constructor
Creates a new Emitter.
-
#read(io) ⇒ Object
Read from an IO object.
-
#to_hash ⇒ Hash
Converts the event to a hash representation.
-
#write(io) ⇒ Number
Writes the event to an IO object.
Constructor Details
#initialize(hash = {}) ⇒ Event
Creates a new Lwes::Emitter.
19 20 21 22 |
# File 'lib/lwes/event.rb', line 19 def initialize(hash={}) self.name = hash[:name] || "" self.attributes = hash[:attributes] || {} end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
9 10 11 |
# File 'lib/lwes/event.rb', line 9 def attributes @attributes end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/lwes/event.rb', line 9 def name @name end |
Class Method Details
.read(io) ⇒ Lwes::Event
Read from an IO object
41 42 43 44 45 |
# File 'lib/lwes/event.rb', line 41 def self.read(io) event = new event.read(io) event end |
Instance Method Details
#read(io) ⇒ Object
Read from an IO object
33 34 35 36 |
# File 'lib/lwes/event.rb', line 33 def read(io) serializer = Lwes::Serialization::Event.read(io) set_attributes_from_serializer(serializer) end |
#to_hash ⇒ Hash
Converts the event to a hash representation
49 50 51 52 53 54 |
# File 'lib/lwes/event.rb', line 49 def to_hash { :name => name, :attributes => attributes } end |
#write(io) ⇒ Number
Writes the event to an IO object
27 28 29 |
# File 'lib/lwes/event.rb', line 27 def write(io) serializer.write(io) end |