bindata 2.3.3 → 2.3.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bindata might be problematic. Click here for more details.

Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.rdoc +4 -0
  3. data/Rakefile +2 -2
  4. data/examples/gzip.rb +24 -24
  5. data/examples/ip_address.rb +3 -4
  6. data/examples/list.rb +20 -20
  7. data/examples/nbt.rb +14 -14
  8. data/examples/tcp_ip.rb +12 -14
  9. data/lib/bindata/alignment.rb +2 -2
  10. data/lib/bindata/array.rb +22 -23
  11. data/lib/bindata/base.rb +13 -12
  12. data/lib/bindata/base_primitive.rb +20 -17
  13. data/lib/bindata/bits.rb +4 -4
  14. data/lib/bindata/buffer.rb +5 -5
  15. data/lib/bindata/choice.rb +11 -13
  16. data/lib/bindata/count_bytes_remaining.rb +1 -2
  17. data/lib/bindata/delayed_io.rb +11 -11
  18. data/lib/bindata/dsl.rb +57 -64
  19. data/lib/bindata/float.rb +16 -13
  20. data/lib/bindata/int.rb +6 -6
  21. data/lib/bindata/io.rb +16 -16
  22. data/lib/bindata/lazy.rb +3 -3
  23. data/lib/bindata/name.rb +2 -2
  24. data/lib/bindata/offset.rb +3 -3
  25. data/lib/bindata/params.rb +13 -15
  26. data/lib/bindata/primitive.rb +3 -3
  27. data/lib/bindata/registry.rb +12 -12
  28. data/lib/bindata/rest.rb +1 -2
  29. data/lib/bindata/sanitize.rb +17 -18
  30. data/lib/bindata/skip.rb +7 -8
  31. data/lib/bindata/string.rb +6 -6
  32. data/lib/bindata/stringz.rb +3 -3
  33. data/lib/bindata/struct.rb +16 -16
  34. data/lib/bindata/trace.rb +9 -8
  35. data/lib/bindata/version.rb +1 -1
  36. data/lib/bindata/virtual.rb +3 -3
  37. data/lib/bindata/warnings.rb +6 -2
  38. data/test/alignment_test.rb +4 -4
  39. data/test/array_test.rb +29 -29
  40. data/test/base_primitive_test.rb +17 -17
  41. data/test/base_test.rb +6 -6
  42. data/test/bits_test.rb +1 -1
  43. data/test/buffer_test.rb +19 -19
  44. data/test/choice_test.rb +20 -20
  45. data/test/count_bytes_remaining_test.rb +1 -1
  46. data/test/delayed_io_test.rb +26 -26
  47. data/test/lazy_test.rb +16 -16
  48. data/test/offset_test.rb +8 -8
  49. data/test/params_test.rb +11 -11
  50. data/test/primitive_test.rb +11 -11
  51. data/test/record_test.rb +50 -50
  52. data/test/registry_test.rb +26 -26
  53. data/test/rest_test.rb +1 -1
  54. data/test/skip_test.rb +27 -27
  55. data/test/string_test.rb +24 -24
  56. data/test/stringz_test.rb +1 -1
  57. data/test/struct_test.rb +76 -75
  58. data/test/system_test.rb +51 -51
  59. data/test/virtual_test.rb +3 -3
  60. metadata +2 -2
data/lib/bindata/float.rb CHANGED
@@ -6,6 +6,18 @@ module BinData
6
6
 
7
7
  module FloatingPoint #:nodoc: all
8
8
  class << self
9
+ PRECISION = {
10
+ single: 4,
11
+ double: 8,
12
+ }
13
+
14
+ PACK_CODE = {
15
+ [:single, :little] => 'e',
16
+ [:single, :big] => 'g',
17
+ [:double, :little] => 'E',
18
+ [:double, :big] => 'G',
19
+ }
20
+
9
21
  def define_methods(float_class, precision, endian)
10
22
  float_class.module_eval <<-END
11
23
  def do_num_bytes
@@ -30,27 +42,18 @@ module BinData
30
42
  end
31
43
 
32
44
  def create_num_bytes_code(precision)
33
- (precision == :single) ? 4 : 8
45
+ PRECISION[precision]
34
46
  end
35
47
 
36
48
  def create_read_code(precision, endian)
37
- if precision == :single
38
- unpack = (endian == :little) ? 'e' : 'g'
39
- nbytes = 4
40
- else # double_precision
41
- unpack = (endian == :little) ? 'E' : 'G'
42
- nbytes = 8
43
- end
49
+ nbytes = PRECISION[precision]
50
+ unpack = PACK_CODE[[precision, endian]]
44
51
 
45
52
  "io.readbytes(#{nbytes}).unpack('#{unpack}').at(0)"
46
53
  end
47
54
 
48
55
  def create_to_binary_s_code(precision, endian)
49
- if precision == :single
50
- pack = (endian == :little) ? 'e' : 'g'
51
- else # double_precision
52
- pack = (endian == :little) ? 'E' : 'G'
53
- end
56
+ pack = PACK_CODE[[precision, endian]]
54
57
 
55
58
  "[val].pack('#{pack}')"
56
59
  end
data/lib/bindata/int.rb CHANGED
@@ -96,10 +96,10 @@ module BinData
96
96
  def create_read_assemble_code(nbits, endian, signed)
97
97
  nwords = nbits / bits_per_word(nbits)
98
98
 
99
- idx = (0 ... nwords).to_a
100
- idx.reverse! if (endian == :big)
99
+ idx = (0...nwords).to_a
100
+ idx.reverse! if endian == :big
101
101
 
102
- parts = (0 ... nwords).collect do |i|
102
+ parts = (0...nwords).collect do |i|
103
103
  "(ints.at(#{idx[i]}) << #{bits_per_word(nbits) * i})"
104
104
  end
105
105
  parts[0].sub!(/ << 0\b/, "") # Remove " << 0" for optimisation
@@ -126,7 +126,7 @@ module BinData
126
126
  nwords = nbits / bits_per_word(nbits)
127
127
  mask = (1 << bits_per_word(nbits)) - 1
128
128
 
129
- vals = (0 ... nwords).collect { |i| "val >> #{bits_per_word(nbits) * i}" }
129
+ vals = (0...nwords).collect { |i| "val >> #{bits_per_word(nbits) * i}" }
130
130
  vals[0].sub!(/ >> 0\b/, "") # Remove " >> 0" for optimisation
131
131
  vals.reverse! if (endian == :big)
132
132
 
@@ -157,7 +157,7 @@ module BinData
157
157
  d = directives[bits_per_word(nbits)]
158
158
  d << ((endian == :big) ? ">" : "<") unless d == "C"
159
159
 
160
- if signed == :signed and directives.has_key?(nbits)
160
+ if signed == :signed && directives.key?(nbits)
161
161
  (d * nwords).downcase
162
162
  else
163
163
  d * nwords
@@ -165,7 +165,7 @@ module BinData
165
165
  end
166
166
 
167
167
  def need_signed_conversion_code?(nbits, signed)
168
- signed == :signed and not [64, 32, 16].include?(nbits)
168
+ signed == :signed && ![64, 32, 16].include?(nbits)
169
169
  end
170
170
  end
171
171
  end
data/lib/bindata/io.rb CHANGED
@@ -39,9 +39,9 @@ module BinData
39
39
 
40
40
  def buffer_limited_n(n)
41
41
  if @buffer_end_points
42
- if n.nil? or n > 0
42
+ if n.nil? || n > 0
43
43
  max = @buffer_end_points[1] - offset
44
- n = max if n.nil? or n > max
44
+ n = max if n.nil? || n > max
45
45
  else
46
46
  min = @buffer_end_points[0] - offset
47
47
  n = min if n < min
@@ -51,7 +51,7 @@ module BinData
51
51
  n
52
52
  end
53
53
 
54
- def with_buffer_common(n, &block)
54
+ def with_buffer_common(n)
55
55
  prev = @buffer_end_points
56
56
  if prev
57
57
  avail = prev[1] - offset
@@ -59,7 +59,7 @@ module BinData
59
59
  end
60
60
  @buffer_end_points = [offset, offset + n]
61
61
  begin
62
- block.call(*@buffer_end_points)
62
+ yield(*@buffer_end_points)
63
63
  ensure
64
64
  @buffer_end_points = prev
65
65
  end
@@ -87,10 +87,10 @@ module BinData
87
87
 
88
88
  # All io calls in +block+ are rolled back after this
89
89
  # method completes.
90
- def with_readahead(&block)
90
+ def with_readahead
91
91
  mark = @raw_io.pos
92
92
  begin
93
- block.call
93
+ yield
94
94
  ensure
95
95
  @raw_io.seek(mark, ::IO::SEEK_SET)
96
96
  end
@@ -133,7 +133,7 @@ module BinData
133
133
 
134
134
  # All io calls in +block+ are rolled back after this
135
135
  # method completes.
136
- def with_readahead(&block)
136
+ def with_readahead
137
137
  mark = @offset
138
138
  @read_data = ""
139
139
  @in_readahead = true
@@ -144,7 +144,7 @@ module BinData
144
144
  end
145
145
 
146
146
  begin
147
- block.call
147
+ yield
148
148
  ensure
149
149
  @offset = mark
150
150
  @in_readahead = false
@@ -167,12 +167,12 @@ module BinData
167
167
  def read_raw_with_readahead(n)
168
168
  data = ""
169
169
 
170
- if @read_data.length > 0 and not @in_readahead
170
+ unless @read_data.empty? || @in_readahead
171
171
  bytes_to_consume = [n, @read_data.length].min
172
172
  data << @read_data.slice!(0, bytes_to_consume)
173
173
  n -= bytes_to_consume
174
174
 
175
- if @read_data.length == 0
175
+ if @read_data.empty?
176
176
  class << self
177
177
  alias_method :read_raw, :read_raw_without_readahead
178
178
  end
@@ -247,9 +247,9 @@ module BinData
247
247
 
248
248
  # Sets a buffer of +n+ bytes on the io stream. Any reading or seeking
249
249
  # calls inside the +block+ will be contained within this buffer.
250
- def with_buffer(n, &block)
250
+ def with_buffer(n)
251
251
  with_buffer_common(n) do
252
- block.call
252
+ yield
253
253
  read
254
254
  end
255
255
  end
@@ -384,9 +384,9 @@ module BinData
384
384
  # +block+ will be contained within this buffer. If less than +n+ bytes
385
385
  # are written inside the block, the remainder will be padded with '\0'
386
386
  # bytes.
387
- def with_buffer(n, &block)
388
- with_buffer_common(n) do |buf_start, buf_end|
389
- block.call
387
+ def with_buffer(n)
388
+ with_buffer_common(n) do |_buf_start, buf_end|
389
+ yield
390
390
  write("\0" * (buf_end - offset))
391
391
  end
392
392
  end
@@ -435,7 +435,7 @@ module BinData
435
435
  writebits(0, 8 - @wnbits, @wendian)
436
436
  end
437
437
  end
438
- alias_method :flush, :flushbits
438
+ alias flush flushbits
439
439
 
440
440
  #---------------
441
441
  private
data/lib/bindata/lazy.rb CHANGED
@@ -3,7 +3,7 @@ module BinData
3
3
  # lambdas in the context of this data object. These lambdas
4
4
  # are those that are passed to data objects as parameters, e.g.:
5
5
  #
6
- # BinData::String.new(:value => lambda { %w{a test message}.join(" ") })
6
+ # BinData::String.new(value: -> { %w(a test message).join(" ") })
7
7
  #
8
8
  # As a shortcut, :foo is the equivalent of lambda { foo }.
9
9
  #
@@ -48,7 +48,7 @@ module BinData
48
48
  # Returns the index of this data object inside it's nearest container
49
49
  # array.
50
50
  def index
51
- return @overrides[:index] if defined? @overrides and @overrides.has_key?(:index)
51
+ return @overrides[:index] if defined?(@overrides) && @overrides.key?(:index)
52
52
 
53
53
  child = @obj
54
54
  parent = @obj.parent
@@ -63,7 +63,7 @@ module BinData
63
63
  end
64
64
 
65
65
  def method_missing(symbol, *args)
66
- return @overrides[symbol] if defined? @overrides and @overrides.has_key?(symbol)
66
+ return @overrides[symbol] if defined?(@overrides) && @overrides.key?(symbol)
67
67
 
68
68
  if @obj.parent
69
69
  eval_symbol_in_parent_context(symbol, args)
data/lib/bindata/name.rb CHANGED
@@ -8,8 +8,8 @@ module BinData
8
8
  # set explicitly. This is only useful when dynamically
9
9
  # generating types.
10
10
  # <code><pre>
11
- # BinData::Struct.new(:name => :my_struct, :fields => ...)
12
- # array = BinData::Array.new(:type => :my_struct)
11
+ # BinData::Struct.new(name: :my_struct, fields: ...)
12
+ # array = BinData::Array.new(type: :my_struct)
13
13
  # </pre></code>
14
14
  module RegisterNamePlugin
15
15
 
@@ -48,11 +48,11 @@ module BinData
48
48
 
49
49
  def check_offset(io)
50
50
  actual_offset = io.offset
51
- expected = eval_parameter(:check_offset, :offset => actual_offset)
51
+ expected = eval_parameter(:check_offset, offset: actual_offset)
52
52
 
53
- if not expected
53
+ if !expected
54
54
  raise ValidityError, "offset not as expected for #{debug_name}"
55
- elsif actual_offset != expected and expected != true
55
+ elsif actual_offset != expected && expected != true
56
56
  raise ValidityError,
57
57
  "offset is '#{actual_offset}' but " +
58
58
  "expected '#{expected}' for #{debug_name}"
@@ -23,17 +23,16 @@ module BinData
23
23
  accepted_parameters.mutually_exclusive(*args)
24
24
  end
25
25
 
26
- alias_method :mandatory_parameter, :mandatory_parameters
27
- alias_method :optional_parameter, :optional_parameters
28
- alias_method :default_parameter, :default_parameters
26
+ alias mandatory_parameter mandatory_parameters
27
+ alias optional_parameter optional_parameters
28
+ alias default_parameter default_parameters
29
29
 
30
30
  def accepted_parameters #:nodoc:
31
- unless defined? @accepted_parameters
31
+ @accepted_parameters ||= begin
32
32
  ancestor_params = superclass.respond_to?(:accepted_parameters) ?
33
33
  superclass.accepted_parameters : nil
34
- @accepted_parameters = AcceptedParameters.new(ancestor_params)
34
+ AcceptedParameters.new(ancestor_params)
35
35
  end
36
- @accepted_parameters
37
36
  end
38
37
 
39
38
  # BinData objects accept parameters when initializing. AcceptedParameters
@@ -55,7 +54,7 @@ module BinData
55
54
  end
56
55
 
57
56
  def mandatory(*args)
58
- if not args.empty?
57
+ unless args.empty?
59
58
  @mandatory.concat(to_syms(args))
60
59
  @mandatory.uniq!
61
60
  end
@@ -63,7 +62,7 @@ module BinData
63
62
  end
64
63
 
65
64
  def optional(*args)
66
- if not args.empty?
65
+ unless args.empty?
67
66
  @optional.concat(to_syms(args))
68
67
  @optional.uniq!
69
68
  end
@@ -82,7 +81,7 @@ module BinData
82
81
 
83
82
  def mutually_exclusive(*args)
84
83
  arg1 = args.shift
85
- while not args.empty?
84
+ until args.empty?
86
85
  args.each do |arg2|
87
86
  @mutually_exclusive.push([arg1.to_sym, arg2.to_sym])
88
87
  @mutually_exclusive.uniq!
@@ -100,7 +99,7 @@ module BinData
100
99
  private
101
100
 
102
101
  def to_syms(args)
103
- syms = args.collect { |el| el.to_sym }
102
+ syms = args.collect(&:to_sym)
104
103
  ensure_valid_names(syms)
105
104
  syms
106
105
  end
@@ -109,22 +108,21 @@ module BinData
109
108
  invalid_names = self.class.invalid_parameter_names
110
109
  names.each do |name|
111
110
  if invalid_names.include?(name)
112
- raise NameError.new("Rename parameter '#{name}' " +
111
+ raise NameError.new("Rename parameter '#{name}' " \
113
112
  "as it shadows an existing method.", name)
114
113
  end
115
114
  end
116
115
  end
117
116
 
118
117
  def self.invalid_parameter_names
119
- unless defined? @invalid_names
118
+ @invalid_names ||= begin
120
119
  all_names = LazyEvaluator.instance_methods(true) + Kernel.methods
121
120
  allowed_names = [:name, :type]
122
121
  invalid_names = (all_names - allowed_names).uniq
123
- @invalid_names = Hash[*invalid_names.collect { |key| [key.to_sym, true] }.flatten]
122
+
123
+ Hash[*invalid_names.collect { |key| [key.to_sym, true] }.flatten]
124
124
  end
125
- @invalid_names
126
125
  end
127
126
  end
128
127
  end
129
128
  end
130
-
@@ -14,8 +14,8 @@ module BinData
14
14
  # require 'bindata'
15
15
  #
16
16
  # class PascalString < BinData::Primitive
17
- # uint8 :len, :value => lambda { data.length }
18
- # string :data, :read_length => :len
17
+ # uint8 :len, value: -> { data.length }
18
+ # string :data, read_length: :len
19
19
  #
20
20
  # def get
21
21
  # self.data
@@ -26,7 +26,7 @@ module BinData
26
26
  # end
27
27
  # end
28
28
  #
29
- # ps = PascalString.new(:initial_value => "hello")
29
+ # ps = PascalString.new(initial_value: "hello")
30
30
  # ps.to_binary_s #=> "\005hello"
31
31
  # ps.read("\003abcde")
32
32
  # ps #=> "abc"
@@ -44,8 +44,8 @@ module BinData
44
44
  # Convert CamelCase +name+ to underscore style.
45
45
  def underscore_name(name)
46
46
  name.to_s.sub(/.*::/, "").
47
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
48
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
47
+ gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
48
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
49
49
  tr("-", "_").
50
50
  downcase
51
51
  end
@@ -56,17 +56,17 @@ module BinData
56
56
  def normalize_name(name, hints)
57
57
  name = underscore_name(name)
58
58
 
59
- if not is_registered?(name)
59
+ if !registered?(name)
60
60
  search_prefix = [""].concat(Array(hints[:search_prefix]))
61
61
  search_prefix.each do |prefix|
62
62
  nwp = name_with_prefix(name, prefix)
63
- if is_registered?(nwp)
63
+ if registered?(nwp)
64
64
  name = nwp
65
65
  break
66
66
  end
67
67
 
68
68
  nwe = name_with_endian(nwp, hints[:endian])
69
- if is_registered?(nwe)
69
+ if registered?(nwe)
70
70
  name = nwe
71
71
  break
72
72
  end
@@ -96,17 +96,17 @@ module BinData
96
96
  end
97
97
  end
98
98
 
99
- def is_registered?(name)
100
- register_dynamic_class(name) unless @registry.has_key?(name)
99
+ def registered?(name)
100
+ register_dynamic_class(name) unless @registry.key?(name)
101
101
 
102
- @registry.has_key?(name)
102
+ @registry.key?(name)
103
103
  end
104
104
 
105
105
  def register_dynamic_class(name)
106
- if /^u?int\d+(le|be)$/ =~ name or /^s?bit\d+(le)?$/ =~ name
106
+ if /^u?int\d+(le|be)$/ =~ name || /^s?bit\d+(le)?$/ =~ name
107
107
  class_name = name.gsub(/(?:^|_)(.)/) { $1.upcase }
108
108
  begin
109
- BinData::const_get(class_name)
109
+ BinData.const_get(class_name)
110
110
  rescue NameError
111
111
  end
112
112
  end
@@ -114,8 +114,8 @@ module BinData
114
114
 
115
115
  def warn_if_name_is_already_registered(name, class_to_register)
116
116
  prev_class = @registry[name]
117
- if $VERBOSE and prev_class and prev_class != class_to_register
118
- warn "warning: replacing registered class #{prev_class} " +
117
+ if $VERBOSE && prev_class && prev_class != class_to_register
118
+ warn "warning: replacing registered class #{prev_class} " \
119
119
  "with #{class_to_register}"
120
120
  end
121
121
  end
data/lib/bindata/rest.rb CHANGED
@@ -7,7 +7,7 @@ module BinData
7
7
  # require 'bindata'
8
8
  #
9
9
  # class A < BinData::Record
10
- # string :a, :read_length => 5
10
+ # string :a, read_length: 5
11
11
  # rest :rest
12
12
  # end
13
13
  #
@@ -16,7 +16,6 @@ module BinData
16
16
  # obj.rest #=" "fghij"
17
17
  #
18
18
  class Rest < BinData::BasePrimitive
19
-
20
19
  #---------------
21
20
  private
22
21
 
@@ -101,15 +101,15 @@ module BinData
101
101
  end
102
102
 
103
103
  def field_names
104
- @fields.collect { |field| field.name_as_sym }
104
+ @fields.collect(&:name_as_sym)
105
105
  end
106
106
 
107
- def has_field_name?(name)
107
+ def field_name?(name)
108
108
  @fields.detect { |f| f.name_as_sym == name.to_sym }
109
109
  end
110
110
 
111
111
  def all_field_names_blank?
112
- @fields.all? { |f| f.name == nil }
112
+ @fields.all? { |f| f.name.nil? }
113
113
  end
114
114
 
115
115
  def no_field_names_blank?
@@ -200,25 +200,25 @@ module BinData
200
200
  self[:endian] ||= hints[:endian]
201
201
  end
202
202
 
203
- if hints[:search_prefix] and not hints[:search_prefix].empty?
203
+ if hints[:search_prefix] && !hints[:search_prefix].empty?
204
204
  self[:search_prefix] = Array(self[:search_prefix]).concat(Array(hints[:search_prefix]))
205
205
  end
206
206
 
207
207
  sanitize!
208
208
  end
209
209
 
210
- alias_method :has_parameter?, :has_key?
210
+ alias_method :has_parameter?, :key?
211
211
 
212
212
  def needs_sanitizing?(key)
213
213
  parameter = self[key]
214
214
 
215
- parameter and not parameter.is_a?(SanitizedParameter)
215
+ parameter && !parameter.is_a?(SanitizedParameter)
216
216
  end
217
217
 
218
218
  def warn_replacement_parameter(bad_key, suggested_key)
219
219
  if has_parameter?(bad_key)
220
- Kernel.warn ":#{bad_key} is not used with #{@the_class}. " +
221
- "You probably want to change this to :#{suggested_key}"
220
+ Kernel.warn ":#{bad_key} is not used with #{@the_class}. " \
221
+ "You probably want to change this to :#{suggested_key}"
222
222
  end
223
223
  end
224
224
 
@@ -226,7 +226,7 @@ module BinData
226
226
  # val = delete(old_key)
227
227
  # if val
228
228
  # self[new_key] = val
229
- # Kernel.warn ":#{old_key} has been renamed to :#{new_key} in #{@the_class}. " +
229
+ # Kernel.warn ":#{old_key} has been renamed to :#{new_key} in #{@the_class}. " \
230
230
  # "Using :#{old_key} is now deprecated and will be removed in the future"
231
231
  # end
232
232
  # end
@@ -235,10 +235,10 @@ module BinData
235
235
  keys.each do |key|
236
236
  if has_parameter?(key)
237
237
  parameter = self[key]
238
- unless Symbol === parameter or
239
- parameter.respond_to? :arity or
240
- parameter.respond_to? :to_int
241
- raise ArgumentError, "parameter '#{key}' in #{@the_class} must " +
238
+ unless Symbol === parameter ||
239
+ parameter.respond_to?(:arity) ||
240
+ parameter.respond_to?(:to_int)
241
+ raise ArgumentError, "parameter '#{key}' in #{@the_class} must " \
242
242
  "evaluate to an integer, got #{parameter.class}"
243
243
  end
244
244
  end
@@ -246,7 +246,7 @@ module BinData
246
246
  end
247
247
 
248
248
  def hints
249
- { :endian => self[:endian], :search_prefix => self[:search_prefix] }
249
+ { endian: self[:endian], search_prefix: self[:search_prefix] }
250
250
  end
251
251
 
252
252
  def create_sanitized_endian(endian)
@@ -255,7 +255,7 @@ module BinData
255
255
  elsif endian == :little
256
256
  LITTLE_ENDIAN
257
257
  elsif endian == :big_and_little
258
- raise ArgumentError, ":endian => :big or :endian => :little is required"
258
+ raise ArgumentError, "endian: :big or endian: :little is required"
259
259
  else
260
260
  raise ArgumentError, "unknown value for endian '#{endian}'"
261
261
  end
@@ -318,13 +318,12 @@ module BinData
318
318
  return if length < 2
319
319
 
320
320
  @the_class.mutually_exclusive_parameters.each do |key1, key2|
321
- if has_parameter?(key1) and has_parameter?(key2)
322
- raise ArgumentError, "params '#{key1}' and '#{key2}' " +
321
+ if has_parameter?(key1) && has_parameter?(key2)
322
+ raise ArgumentError, "params '#{key1}' and '#{key2}' " \
323
323
  "are mutually exclusive in #{@the_class}"
324
324
  end
325
325
  end
326
326
  end
327
327
  end
328
328
  #----------------------------------------------------------------------------
329
-
330
329
  end