Module: CLValueBytesParsers::CLU64BytesParser

Extended by:
CLU64BytesParser
Included in:
CLU64BytesParser, CLu64
Defined in:
lib/serialization/cl_value_bytes_parsers.rb

Instance Method Summary collapse

Instance Method Details

#from_bytes(byte_array) ⇒ Object



147
148
149
# File 'lib/serialization/cl_value_bytes_parsers.rb', line 147

def from_bytes(byte_array)
    byte_array.reverse.inject(0) {|m, b| (m << 8) + b }
end

#to_bytes(value) ⇒ Object



151
152
153
154
155
156
157
# File 'lib/serialization/cl_value_bytes_parsers.rb', line 151

def to_bytes(value)
  if value < 0 || value > MAX_U64
    "Parameter value '#{value}' is out of range."
  else
    [value].pack("Q<*").unpack("C*")
  end
end