Module: Trxl::ValuesOfTypeFunction1

Defined in:
lib/trxl/trxl_grammar.rb

Instance Method Summary collapse

Instance Method Details

#eval(env = Environment.new) ⇒ Object



8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
# File 'lib/trxl/trxl_grammar.rb', line 8426

def eval(env = Environment.new)
  types = all_types.eval(env)
  if types.is_a?(Hash)
    values = all_values.eval(env)
    if values.is_a?(Hash)
      types.select { |k, v| v == match_exp.eval(env) }.map do |entry|
        values[entry[0]]
      end
    else
      raise Trxl::InvalidArgumentException, "Third parameter must be a Hash"
    end
  else
    raise Trxl::InvalidArgumentException, "Second parameter must be a Hash"
  end
end