Module: Ruby::SerialData
- Included in:
- SerialString
- Defined in:
- lib/ruby/proto.rb
Class Method Summary collapse
Instance Method Summary collapse
- #loadInt16 ⇒ Object
- #loadInt32 ⇒ Object
- #loadInt8 ⇒ Object
- #storeInt16(_value) ⇒ Object
- #storeInt32(_value) ⇒ Object
- #storeInt8(_value) ⇒ Object
Class Method Details
.byteArrayToInt(_arr) ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'lib/ruby/proto.rb', line 79 def byteArrayToInt(_arr) value = 0 _arr.reverse_each do |_byte| # puts "#{__callee__} byte:[#{_byte}]" value = value << 8 value = value | _byte end value end |
.intToByteArray(_value, _length = 4) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/ruby/proto.rb', line 69 def intToByteArray(_value, _length = 4) arr = [] _length.times do |_index| val = _value & 0xff; _value = _value >> 8; arr.push(val) end arr end |
Instance Method Details
#loadInt16 ⇒ Object
106 107 108 |
# File 'lib/ruby/proto.rb', line 106 def loadInt16 doLoadInt_(2) end |
#loadInt32 ⇒ Object
110 111 112 |
# File 'lib/ruby/proto.rb', line 110 def loadInt32 doLoadInt_(4) end |
#loadInt8 ⇒ Object
102 103 104 |
# File 'lib/ruby/proto.rb', line 102 def loadInt8 doLoadInt_(1) end |
#storeInt16(_value) ⇒ Object
94 95 96 |
# File 'lib/ruby/proto.rb', line 94 def storeInt16(_value) doStoreInt_(_value, 2) end |
#storeInt32(_value) ⇒ Object
90 91 92 |
# File 'lib/ruby/proto.rb', line 90 def storeInt32(_value) doStoreInt_(_value, 4) end |
#storeInt8(_value) ⇒ Object
98 99 100 |
# File 'lib/ruby/proto.rb', line 98 def storeInt8(_value) doStoreInt_(_value, 1) end |