Class: Eqn::Terminal::Variable

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

Overview

Node class for a variable.

Instance Method Summary collapse

Methods inherited from EqnNode

#clean_tree!, #term?

Instance Method Details

#value(vars = {}) ⇒ Object



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

def value(vars = {})
  val = vars[text_value.to_sym]
  raise NoVariableValueError, "No value given for: #{text_value}" unless val
  raise NonNumericVariableError, "Variable #{text_value} value is nonnumeric: #{val}" unless val.is_a?(Numeric)

  val
end