Class: DL::Packer
Constant Summary
Constants included
from PackInfo
DL::PackInfo::ALIGN_MAP, DL::PackInfo::PACK_MAP, DL::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.
70
71
72
|
# File 'lib/dl/pack.rb', line 70
def initialize(types)
parse_types(types)
end
|
Class Method Details
.[](*types) ⇒ Object
66
67
68
|
# File 'lib/dl/pack.rb', line 66
def self.[](*types)
new(types)
end
|
Instance Method Details
#pack(ary) ⇒ Object
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/dl/pack.rb', line 78
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
74
75
76
|
# File 'lib/dl/pack.rb', line 74
def size()
@size
end
|
#unpack(ary) ⇒ Object
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/dl/pack.rb', line 89
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
|