Class: RSwim::Message
- Inherits:
-
Object
- Object
- RSwim::Message
- Defined in:
- lib/rswim/message.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(to, from, type, payload = {}) ⇒ Message
constructor
A new instance of Message.
- #to_s ⇒ Object
Constructor Details
#initialize(to, from, type, payload = {}) ⇒ Message
Returns a new instance of Message.
7 8 9 10 11 12 |
# File 'lib/rswim/message.rb', line 7 def initialize(to, from, type, payload = {}) @to = to @from = from @type = type @payload = payload end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
5 6 7 |
# File 'lib/rswim/message.rb', line 5 def from @from end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
5 6 7 |
# File 'lib/rswim/message.rb', line 5 def payload @payload end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
5 6 7 |
# File 'lib/rswim/message.rb', line 5 def to @to end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/rswim/message.rb', line 5 def type @type end |
Instance Method Details
#==(other) ⇒ Object
18 19 20 |
# File 'lib/rswim/message.rb', line 18 def ==(other) %i[to from type payload].all? { |a| send(a) == other.send(a) } end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/rswim/message.rb', line 14 def to_s "message of type #{type} from #{from} to #{to} with #{payload[:updates].to_a.size} updates" end |