class Teacher::Function
Public Class Methods
new(scope, &block)
click to toggle source
# File lib/teacher/function.rb, line 4 def initialize(scope, &block) @scope = scope @body = block end
Public Instance Methods
call(scope, args)
click to toggle source
# File lib/teacher/function.rb, line 9 def call(scope, args) args.reject! { |a| a.text_value.blank? } if args.to_a.any? tmp = [args.first] if args.length > 1 last = args.last.elements.first if last.is_a?(List) tmp += last.eval(self) else tmp << last end end args = tmp end @body.call(*args) end