Module: BinData::IntFactory
- Included in:
- BinData
- Defined in:
- lib/bindata/int.rb
Overview
Create classes on demand
Instance Method Summary collapse
Instance Method Details
#const_missing(name) ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# 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 |