Class: Canoser::Bool
- Inherits:
-
Object
- Object
- Canoser::Bool
- Defined in:
- lib/canoser/field.rb
Class Method Summary collapse
Class Method Details
.decode(cursor) ⇒ Object
76 77 78 79 |
# File 'lib/canoser/field.rb', line 76 def self.decode(cursor) bytes = cursor.read_bytes(1) decode_bytes(bytes) end |
.decode_bytes(bytes) ⇒ Object
70 71 72 73 74 |
# File 'lib/canoser/field.rb', line 70 def self.decode_bytes(bytes) return true if bytes == "\1" return false if bytes == "\0" raise ParseError.new("bool should be 0 or 1.") end |
.encode(value) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/canoser/field.rb', line 62 def self.encode(value) if value "\1" else "\0" end end |