Class: BinData::SanitizedChoices

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

Overview


Instance Method Summary collapse

Constructor Details

#initialize(choices, hints) ⇒ SanitizedChoices

Returns a new instance of SanitizedChoices.



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/bindata/sanitize.rb', line 133

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

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

Instance Method Details

#[](key) ⇒ Object



151
152
153
# File 'lib/bindata/sanitize.rb', line 151

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