Module: Gonzui::DeltaDumper
- Defined in:
- lib/gonzui/delta.rb,
ext/delta/delta.c
Constant Summary collapse
- PACK_FORMAT =
"w*"
Class Method Summary collapse
- .decode_fixnums(list) ⇒ Object
- .decode_tuples(list, delta_size, unit_size) ⇒ Object
- .dump_fixnums(list) ⇒ Object (also: dump_ids)
- .dump_tuples(klass, list) ⇒ Object
- .encode_fixnums(list) ⇒ Object
- .encode_tuples(list, delta_size, unit_size) ⇒ Object
- .undump_fixnums(dump) ⇒ Object (also: undump_ids)
- .undump_tuples(klass, dump) ⇒ Object
Class Method Details
.decode_fixnums(list) ⇒ Object
120 121 122 123 124 |
# File 'ext/delta/delta.c', line 120
static VALUE
rb_delta_decode_fixnums(VALUE obj, VALUE list)
{
rb_delta_code_fixnums(obj, list, decode);
}
|
.decode_tuples(list, delta_size, unit_size) ⇒ Object
88 89 90 91 92 93 |
# File 'ext/delta/delta.c', line 88
static VALUE
rb_delta_decode_tuples(VALUE obj, VALUE list,
VALUE delta_size, VALUE unit_size)
{
return rb_delta_code_tuples(obj, list, delta_size, unit_size, decode);
}
|
.dump_fixnums(list) ⇒ Object Also known as: dump_ids
37 38 39 |
# File 'lib/gonzui/delta.rb', line 37 def dump_fixnums(list) encode_fixnums(list).pack(PACK_FORMAT) end |
.dump_tuples(klass, list) ⇒ Object
19 20 21 22 |
# File 'lib/gonzui/delta.rb', line 19 def dump_tuples(klass, list) encode_tuples(list, klass::DeltaSize, klass::UnitSize) return list.pack(PACK_FORMAT) end |
.encode_fixnums(list) ⇒ Object
126 127 128 129 130 |
# File 'ext/delta/delta.c', line 126
static VALUE
rb_delta_encode_fixnums(VALUE obj, VALUE list)
{
rb_delta_code_fixnums(obj, list, encode);
}
|
.encode_tuples(list, delta_size, unit_size) ⇒ Object
95 96 97 98 99 100 |
# File 'ext/delta/delta.c', line 95
static VALUE
rb_delta_encode_tuples(VALUE obj, VALUE list,
VALUE delta_size, VALUE unit_size)
{
return rb_delta_code_tuples(obj, list, delta_size, unit_size, encode);
}
|
.undump_fixnums(dump) ⇒ Object Also known as: undump_ids
41 42 43 |
# File 'lib/gonzui/delta.rb', line 41 def undump_fixnums(dump) decode_fixnums(dump.unpack(PACK_FORMAT)) end |
.undump_tuples(klass, dump) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gonzui/delta.rb', line 24 def undump_tuples(klass, dump) list = dump.unpack(PACK_FORMAT) decode_tuples(list, klass::DeltaSize, klass::UnitSize) # # Make an array of arrays for convinence of the caller # [1,2,3,4,5,6] => [[1,2], [3,4], [5,6] if UnitSize is 2 # values = (0...(list.length / klass::UnitSize)).map {|i| list[i * klass::UnitSize, klass::UnitSize] } return values end |