Class: Lwes::Serialization::Boolean
- Inherits:
-
BinData::BasePrimitive
- Object
- BinData::BasePrimitive
- Lwes::Serialization::Boolean
- Defined in:
- lib/lwes/serialization.rb
Instance Method Summary collapse
- #read_and_return_value(io) ⇒ Object
- #read_uint8(io) ⇒ Object
- #sensible_default ⇒ Object
- #value_to_binary_string(value) ⇒ Object
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_default ⇒ Object
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 |