packed_struct 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -154,7 +154,7 @@ module PackedStruct
|
|
154
154
|
def size
|
155
155
|
case @tags[:size]
|
156
156
|
when Directive
|
157
|
-
(@tags[:size].value || 0) + (@tags[:size].tags[:size_modify] || 0)
|
157
|
+
(@tags[:size].value || 0).to_i + (@tags[:size].tags[:size_modify] || 0).to_i
|
158
158
|
when Numeric
|
159
159
|
@tags[:size]
|
160
160
|
when nil
|
@@ -23,7 +23,7 @@ module PackedStruct
|
|
23
23
|
#
|
24
24
|
# @return [String] the string ready for #pack.
|
25
25
|
def to_s
|
26
|
-
|
26
|
+
directives.map(&:to_s).join(' ')
|
27
27
|
end
|
28
28
|
|
29
29
|
alias_method :to_str, :to_s
|
@@ -41,8 +41,10 @@ module PackedStruct
|
|
41
41
|
|
42
42
|
mapped_directives = @directives.map(&:name)
|
43
43
|
|
44
|
-
values.
|
45
|
-
|
44
|
+
values.select! { |x| mapped_directives.include?(x[0]) }
|
45
|
+
|
46
|
+
values.sort! do |a, b|
|
47
|
+
o = mapped_directives.index(a[0]) <=> mapped_directives.index(b[0])
|
46
48
|
end
|
47
49
|
|
48
50
|
pack_with_array(values.map(&:last))
|
@@ -116,7 +118,6 @@ module PackedStruct
|
|
116
118
|
if @directives.map(&:name).include?(method) && arguments.length == 0
|
117
119
|
@directives.select { |x| x.name == method }.first
|
118
120
|
else
|
119
|
-
@_str = nil
|
120
121
|
directive = Directive.new(method, *arguments)
|
121
122
|
@directives << directive
|
122
123
|
directive
|