Module: CLValueBytesParsers::CLU512BytesParser
- Extended by:
- CLU512BytesParser
- Included in:
- CLU512BytesParser, CLu512
- Defined in:
- lib/serialization/cl_value_bytes_parsers.rb
Instance Method Summary collapse
Instance Method Details
#from_bytes(byte_array) ⇒ Object
196 197 198 |
# File 'lib/serialization/cl_value_bytes_parsers.rb', line 196 def from_bytes(byte_array) byte_array.reverse.inject(0) {|m, b| (m << 8) + b } end |
#to_bytes(value) ⇒ Object
200 201 202 203 204 205 206 207 208 |
# File 'lib/serialization/cl_value_bytes_parsers.rb', line 200 def to_bytes(value) if value < 0 || value > MAX_U512 "Parameter value '#{value}' is out of range." else str = value.to_s(16) arr = str.scan(/[0-9a-f]{4}/).map { |x| x.to_i(16) } packed = arr.pack("n*").unpack("C*").reverse() end end |