Class: Keisan::Interpreter

Inherits:
Object
  • Object
show all
Defined in:
lib/keisan/interpreter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allow_recursive: false) ⇒ Interpreter

Returns a new instance of Interpreter.



7
8
9
# File 'lib/keisan/interpreter.rb', line 7

def initialize(allow_recursive: false)
  @calculator = Calculator.new(allow_recursive: allow_recursive)
end

Instance Attribute Details

#calculatorObject (readonly)

Returns the value of attribute calculator.



5
6
7
# File 'lib/keisan/interpreter.rb', line 5

def calculator
  @calculator
end

Instance Method Details

#run(file_name) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/keisan/interpreter.rb', line 11

def run(file_name)
  if file_name.nil?
    run_from_stdin
  else
    run_from_file(file_name)
  end
end