Module: BinData::BitFieldFactory
- Included in:
- BinData
- Defined in:
- lib/bindata/bits.rb
Overview
Create classes on demand
Instance Method Summary collapse
Instance Method Details
#const_missing(name) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/bindata/bits.rb', line 90 def const_missing(name) mappings = { /^Bit(\d+)$/ => :big, /^Bit(\d+)le$/ => :little, /^Sbit(\d+)$/ => [:big, :signed], /^Sbit(\d+)le$/ => [:little, :signed] } mappings.each_pair do |regex, args| if regex =~ name.to_s nbits = $1.to_i return BitField.define_class(nbits, *args) end end super(name) end |