module SQLite3ExtendFunction::Functions::Radians

SQLite3ExtendFunction::Functions::Radians

Public Class Methods

call(dp) click to toggle source

@param [Integer, Float] dp @return [Integer, Float] @raise [SQLite3::SQLException]

# File lib/sqlite3_extend_function/functions/radians.rb, line 11
def call(dp)
  return if dp.nil?

  result = Float(dp) * Math::PI / 180
  result.to_i == result ? result.to_i : result
rescue ArgumentError
  raise SQLite3::SQLException, "invalid input syntax for type double precision: \"#{dp}\""
end