Class: Lwes::Serialization::Boolean

Inherits:
BinData::BasePrimitive
  • Object
show all
Defined in:
lib/lwes/serialization.rb

Instance Method Summary collapse

Instance Method Details

#read_and_return_value(io) ⇒ Object



12
13
14
15
# File 'lib/lwes/serialization.rb', line 12

def read_and_return_value(io)
  byte = read_uint8(io)
  byte != 0 # 0 is false, everything else is true
end

#read_uint8(io) ⇒ Object



21
22
23
# File 'lib/lwes/serialization.rb', line 21

def read_uint8(io)
  io.readbytes(1).unpack("C").at(0)
end

#sensible_defaultObject



17
18
19
# File 'lib/lwes/serialization.rb', line 17

def sensible_default
  false
end

#value_to_binary_string(value) ⇒ Object



8
9
10
# File 'lib/lwes/serialization.rb', line 8

def value_to_binary_string(value)
  value ? 1.chr : 0.chr
end