lib/bindata/int.rb in bindata-1.5.1 vs lib/bindata/int.rb in bindata-1.6.0

- old
+ new

@@ -155,30 +155,28 @@ class Int8 < BinData::BasePrimitive Int.define_methods(self, 8, :little, :signed) end # Create classes on demand - class << self - alias_method :const_missing_without_int, :const_missing - def const_missing_with_int(name) - name = name.to_s + module IntFactory + def const_missing(name) mappings = { /^Uint(\d+)be$/ => [:big, :unsigned], /^Uint(\d+)le$/ => [:little, :unsigned], /^Int(\d+)be$/ => [:big, :signed], /^Int(\d+)le$/ => [:little, :signed], } mappings.each_pair do |regex, args| - if regex =~ name + if regex =~ name.to_s nbits = $1.to_i if (nbits % 8).zero? return Int.define_class(nbits, *args) end end end - const_missing_without_int(name) + super end - alias_method :const_missing, :const_missing_with_int end + BinData.extend IntFactory end