packed_struct 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- @_str ||= directives.map(&:to_s).join(' ')
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.sort do |a, b|
45
- directives.index(a) <=> directives.index(b)
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
@@ -1,5 +1,5 @@
1
1
  module PackedStruct
2
2
 
3
3
  # The current version of PackedStruct.
4
- VERSION = "0.1.0".freeze
4
+ VERSION = "0.1.1".freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packed_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: