Class: MTP::Data
Instance Attribute Summary collapse
-
#size ⇒ Object
Returns the value of attribute size.
Attributes inherited from Container
#code, #length, #length_read, #payload, #transaction_id
Instance Method Summary collapse
-
#initialize(payload = nil, size = nil) ⇒ Data
constructor
A new instance of Data.
- #pack_header ⇒ Object
- #type ⇒ Object
Methods inherited from Container
#pack, #pack_payload, parse, #to_s
Constructor Details
#initialize(payload = nil, size = nil) ⇒ Data
Returns a new instance of Data.
85 86 87 88 |
# File 'lib/mtp/container.rb', line 85 def initialize(payload = nil, size = nil) @payload = payload @size = size end |
Instance Attribute Details
#size ⇒ Object
Returns the value of attribute size.
83 84 85 |
# File 'lib/mtp/container.rb', line 83 def size @size end |
Instance Method Details
#pack_header ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/mtp/container.rb', line 94 def pack_header if size.nil? blob = [ type, code, transaction_id ].pack_without_mtp("SSI") + pack_payload return [ blob.length + 4, type, code, transaction_id ].pack_without_mtp("ISSI") else blob = [ 12 + size, type, code, transaction_id ].pack_without_mtp("ISSI") end end |
#type ⇒ Object
90 91 92 |
# File 'lib/mtp/container.rb', line 90 def type 2 end |