Class: ML_ruby::ML_message
- Inherits:
-
Object
- Object
- ML_ruby::ML_message
- Defined in:
- lib/ml-ruby/ml_protocol.rb
Instance Attribute Summary collapse
-
#opcode ⇒ Object
readonly
Returns the value of attribute opcode.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #encode ⇒ Object
-
#initialize(opcode = nil, payload = nil) ⇒ ML_message
constructor
A new instance of ML_message.
Constructor Details
#initialize(opcode = nil, payload = nil) ⇒ ML_message
Returns a new instance of ML_message.
29 30 31 32 33 34 35 36 37 |
# File 'lib/ml-ruby/ml_protocol.rb', line 29 def initialize opcode=nil, payload=nil if opcode && opcode.is_a?( ML_int16 ) @opcode= opcode elsif opcode @opcode= ML_int16.new( opcode ) end @payload= payload if payload @size= ML_int32.new( @opcode.size + (payload ? payload.size : 0) ) if opcode end |
Instance Attribute Details
#opcode ⇒ Object (readonly)
Returns the value of attribute opcode.
28 29 30 |
# File 'lib/ml-ruby/ml_protocol.rb', line 28 def opcode @opcode end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
28 29 30 |
# File 'lib/ml-ruby/ml_protocol.rb', line 28 def payload @payload end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
28 29 30 |
# File 'lib/ml-ruby/ml_protocol.rb', line 28 def size @size end |
Instance Method Details
#encode ⇒ Object
38 39 40 |
# File 'lib/ml-ruby/ml_protocol.rb', line 38 def encode @size.encode + @opcode.encode + @payload.encode end |