Class: Fiddle::Packer
Overview
Constant Summary
Constants included
from PackInfo
Fiddle::PackInfo::ALIGN_MAP, Fiddle::PackInfo::PACK_MAP, Fiddle::PackInfo::SIZE_MAP
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from PackInfo
align
Constructor Details
#initialize(types) ⇒ Packer
Returns a new instance of Packer.
71
72
73
|
# File 'lib/fiddle/pack.rb', line 71
def initialize(types)
parse_types(types)
end
|
Class Method Details
.[](*types) ⇒ Object
67
68
69
|
# File 'lib/fiddle/pack.rb', line 67
def self.[](*types)
new(types)
end
|
Instance Method Details
#pack(ary) ⇒ Object
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/fiddle/pack.rb', line 79
def pack(ary)
case SIZEOF_VOIDP
when SIZEOF_LONG
ary.pack(@template)
when SIZEOF_LONG_LONG
ary.pack(@template)
else
raise(RuntimeError, "sizeof(void*)?")
end
end
|
#size ⇒ Object
75
76
77
|
# File 'lib/fiddle/pack.rb', line 75
def size()
@size
end
|
#unpack(ary) ⇒ Object
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/fiddle/pack.rb', line 90
def unpack(ary)
case SIZEOF_VOIDP
when SIZEOF_LONG
ary.join().unpack(@template)
when SIZEOF_LONG_LONG
ary.join().unpack(@template)
else
raise(RuntimeError, "sizeof(void*)?")
end
end
|