Class: BinData::SanitizedChoices

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

Overview


Instance Method Summary collapse

Constructor Details

#initialize(choices, namespace, hints) ⇒ SanitizedChoices

Returns a new instance of SanitizedChoices.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/bindata/sanitize.rb', line 126

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

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

Instance Method Details

#[](key) ⇒ Object



144
145
146
# File 'lib/bindata/sanitize.rb', line 144

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