Module: CLValueBytesParsers::CLU8BytesParser

Extended by:
CLU8BytesParser
Included in:
CLU8BytesParser, CLu8
Defined in:
lib/serialization/cl_value_bytes_parsers.rb

Instance Method Summary collapse

Instance Method Details

#from_bytes(byte_array) ⇒ Object



116
117
118
# File 'lib/serialization/cl_value_bytes_parsers.rb', line 116

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

#to_bytes(value) ⇒ Object



120
121
122
123
124
125
126
127
# File 'lib/serialization/cl_value_bytes_parsers.rb', line 120

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