class Keisan::Functions::Let
Public Class Methods
new()
click to toggle source
Calls superclass method
Keisan::Function::new
# File lib/keisan/functions/let.rb, line 4 def initialize super("let", ::Range.new(1,2)) end
Public Instance Methods
evaluate(ast_function, context = nil)
click to toggle source
# File lib/keisan/functions/let.rb, line 12 def evaluate(ast_function, context = nil) validate_arguments!(ast_function.children.count) assignment(ast_function).evaluate(context) end
simplify(ast_function, context = nil)
click to toggle source
# File lib/keisan/functions/let.rb, line 17 def simplify(ast_function, context = nil) evaluate(ast_function, context) end
value(ast_function, context = nil)
click to toggle source
# File lib/keisan/functions/let.rb, line 8 def value(ast_function, context = nil) evaluate(ast_function, context) end
Private Instance Methods
assignment(ast_function)
click to toggle source
# File lib/keisan/functions/let.rb, line 23 def assignment(ast_function) if ast_function.children.count == 1 unless ast_function.children.first.is_a?(AST::Assignment) raise Exceptions::InvalidFunctionError.new("`let` must accept assignment if given one argument") end AST::Assignment.new(ast_function.children.first.children, local: true) else AST::Assignment.new(ast_function.children, local: true) end end