Class: TableOfTruth::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/table_of_truth/input.rb

Instance Method Summary collapse

Constructor Details

#initialize(inputs) ⇒ Input



4
5
6
7
# File 'lib/table_of_truth/input.rb', line 4

def initialize(inputs)
  @inputs = inputs
  @inputs.each { |key, value| define_singleton_method(key) { value } }
end

Instance Method Details

#[](key) ⇒ Boolean



11
12
13
14
15
16
17
18
19
# File 'lib/table_of_truth/input.rb', line 11

def [](key)
  if @inputs.key?(key.to_s)
    @inputs[key.to_s]
  elsif @inputs.key?(key.to_sym)
    @inputs[key.to_sym]
  else
    raise KeyError, "key not found: #{key}"
  end
end