Class: BinData::SanitizedChoices

Inherits:
SanitizedParameter show all
Defined in:
lib/bindata/sanitize.rb

Overview


Instance Method Summary collapse

Constructor Details

#initialize(choices, endian) ⇒ SanitizedChoices

Returns a new instance of SanitizedChoices.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/bindata/sanitize.rb', line 113

def initialize(choices, endian)
  @choices = {}
  choices.each_pair do |key, val|
    if SanitizedParameter === val
      prototype = val
    else
      type, param = val
      prototype = SanitizedPrototype.new(type, param, endian)
    end

    if key == :default
      @choices.default = prototype
    else
      @choices[key] = prototype
    end
  end
end

Instance Method Details

#[](key) ⇒ Object



131
132
133
# File 'lib/bindata/sanitize.rb', line 131

def [](key)
  @choices[key]
end