Module: Dawg::Serialization
- Included in:
- Dawg, Dawg, MemoryDawg
- Defined in:
- lib/dawg/serialization.rb
Instance Method Summary collapse
-
#load_bigint(io) ⇒ Object
64bit signed integer.
- #load_bool(io) ⇒ Object
- #load_char(io) ⇒ Object
- #load_int(io) ⇒ Object
- #write_bigint(int, io) ⇒ Object
- #write_bool(var, io) ⇒ Object
- #write_char(char, io) ⇒ Object
-
#write_int(int, io) ⇒ Object
32bit signed integer.
Instance Method Details
#load_bigint(io) ⇒ Object
64bit signed integer
11 12 13 |
# File 'lib/dawg/serialization.rb', line 11 def load_bigint(io) #64bit signed integer io.read(8).unpack('q')[0] end |
#load_bool(io) ⇒ Object
24 25 26 27 |
# File 'lib/dawg/serialization.rb', line 24 def load_bool(io) bool = io.read(1).unpack('c')[0] bool == 1 ? true : false end |
#load_char(io) ⇒ Object
33 34 35 |
# File 'lib/dawg/serialization.rb', line 33 def load_char(io) io.read(4).unpack('Z4')[0].force_encoding('utf-8') end |
#load_int(io) ⇒ Object
3 4 5 |
# File 'lib/dawg/serialization.rb', line 3 def load_int(io) io.read(4).unpack('l')[0] end |
#write_bigint(int, io) ⇒ Object
15 16 17 |
# File 'lib/dawg/serialization.rb', line 15 def write_bigint(int, io) io << [int].pack('q') end |
#write_bool(var, io) ⇒ Object
19 20 21 22 |
# File 'lib/dawg/serialization.rb', line 19 def write_bool(var, io) bool = var ? 1 : 0 io << [bool].pack('c') end |
#write_char(char, io) ⇒ Object
29 30 31 |
# File 'lib/dawg/serialization.rb', line 29 def write_char(char, io) io << [char].pack('Z4') end |
#write_int(int, io) ⇒ Object
32bit signed integer
7 8 9 |
# File 'lib/dawg/serialization.rb', line 7 def write_int(int, io) #32bit signed integer io << [int].pack('l') end |