Class: BareTypes::Bool
- Inherits:
-
BarePrimitive
- Object
- BaseType
- BarePrimitive
- BareTypes::Bool
- Defined in:
- lib/types.rb
Instance Method Summary collapse
Methods inherited from BarePrimitive
#==, #finalize_references, #to_schema
Methods inherited from BaseType
Constructor Details
This class inherits a constructor from BareTypes::BaseType
Instance Method Details
#decode(msg) ⇒ Object
387 388 389 390 391 392 |
# File 'lib/types.rb', line 387 def decode(msg) if msg != "\x00" && msg != "\x01" raise InvalidBool.new("Expected a bool but found #{msg.inspect}. Standard requires bool to be 0x00 or 0x01") end return (msg == "\x00" ? true : false), msg[1..msg.size] end |
#encode(msg, buffer) ⇒ Object
383 384 385 |
# File 'lib/types.rb', line 383 def encode(msg, buffer) buffer << (msg ? "\x00".b : "\x01".b) end |