Module: CLValueBytesParsers::CLBoolBytesParser

Extended by:
CLBoolBytesParser
Included in:
CLBool, CLBoolBytesParser
Defined in:
lib/serialization/cl_value_bytes_parsers.rb

Instance Method Summary collapse

Instance Method Details

#from_bytes(bytes) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/serialization/cl_value_bytes_parsers.rb', line 21

def from_bytes(bytes)
  if bytes.first == 1
    CLBool.new(true) 
  else
    CLBool.new(false) 
  end
end

#to_bytes(clbool) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/serialization/cl_value_bytes_parsers.rb', line 12

def to_bytes(clbool)
  value = clbool.get_value
  if value == true || value == false
    [value.to_i].pack("C").unpack("C")
  else
    "CLValue TypeError"
  end
end