Class: Eqn::Terminal::Variable

Inherits:
Node
  • Object
show all
Defined in:
lib/eqn/terminal.rb

Instance Method Summary collapse

Instance Method Details

#valueObject



6
7
8
9
10
11
12
13
14
# File 'lib/eqn/terminal.rb', line 6

def value
  unless Eqn::Calculator.class_variable_get(:@@vars).key? text_value.intern
    fail NoVariableValueError, "No value given for: #{text_value}"
  end
  unless Eqn::Calculator.class_variable_get(:@@vars)[text_value.intern].is_a? Numeric
    fail NonNumericVariableError, "Variable #{text_value} value is nonnumeric: #{Eqn::Calculator.class_variable_get(:@@vars)[text_value.intern]}"
  end
  Eqn::Calculator.class_variable_get(:@@vars)[text_value.intern]
end