module SQLite3ExtendFunction::Functions::Encode
Public Class Methods
call(data, format)
click to toggle source
@todo implement escape
@param [String] data @param [String] format @return [String, NilClass] @raise [SQLite3::SQLException]
# File lib/sqlite3_extend_function/functions/encode.rb, line 14 def call(data, format) return if data.nil? raise ArgumentError unless data.is_a?(String) return Base64.encode64(data) if format == 'base64' return data.unpack('C*').map { |c| c.to_s(16) }.join if format == 'hex' raise ArgumentError rescue ArgumentError raise SQLite3::SQLException, 'No function matches the given name and argument types. ' \ 'You might need to add explicit type casts.' end