Methods

Files

Class/Module Index [+]

Quicksearch

BinData::IntFactory

Create classes on demand

Public Instance Methods

const_missing(name) click to toggle source
# File lib/bindata/int.rb, line 161
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.to_s
      nbits = $1.to_i
      if (nbits % 8).zero?
        return Int.define_class(nbits, *args)
      end
    end
  end

  super
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.