module SQLite3ExtendFunction::Functions::Log
Public Class Methods
call(y, x = nil)
click to toggle source
@param [Integer, Float] y @param [Integer, Float, NilClass] x @return [Integer, Float] @raise [SQLite3::SQLException]
# File lib/sqlite3_extend_function/functions/log.rb, line 12 def call(y, x = nil) return if y.nil? return Math.log(x, y) unless x.nil? result = Math.log10(Float(y)) result.to_i == result ? result.to_i : result rescue ArgumentError raise SQLite3::SQLException, 'invalid input syntax for type numeric' end