class Soroban::Functions
Public Class Methods
all()
click to toggle source
Return an array of all defined functions.
# File lib/soroban/functions.rb, line 17 def self.all @@_functions.keys.map(&:to_s).to_a.sort end
call(sheet, name, *args)
click to toggle source
Call the named function within the context of the specified sheet, supplying some number of arguments (which is a property of the function, and therefore given as a splat here).
# File lib/soroban/functions.rb, line 24 def self.call(sheet, name, *args) callback = @@_functions[name.to_s.upcase.to_sym] raise Soroban::UndefinedError, "No such function '#{name}'" if callback.nil? sheet.instance_exec(*args, &callback) end
define(function_hash)
click to toggle source
Define one or more functions by passing in a hash mapping function name to the lambda that computes the function's value.
# File lib/soroban/functions.rb, line 9 def self.define(function_hash) @@_functions ||= {} function_hash.each do |name, callback| @@_functions[name.to_s.upcase.to_sym] = callback end end