class SQLite3ExtendFunction::Function

SQLite3ExtendFunction::Function

Public Class Methods

new(mod) click to toggle source

@param [Class] mod @return [void]

# File lib/sqlite3_extend_function/function.rb, line 8
def initialize(mod)
  @mod = mod
end

Public Instance Methods

arity() click to toggle source

@return [Integer]

# File lib/sqlite3_extend_function/function.rb, line 26
def arity
  @mod.method(:call).parameters.size
end
name() click to toggle source

@return [String]

# File lib/sqlite3_extend_function/function.rb, line 13
def name
  @mod.name.split('::').last
      .gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
      .gsub(/([a-z\d])([A-Z])/, '\1_\2')
      .tr('-', '_').downcase
end
to_proc() click to toggle source

@return [Proc]

# File lib/sqlite3_extend_function/function.rb, line 21
def to_proc
  ->(func, *argv) { func.result = @mod.call(*argv) }
end