class SQLite3::Value

Attributes

handle[R]

Public Class Methods

new(db, handle) click to toggle source
# File lib/sqlite3/value.rb, line 8
def initialize(db, handle)
  @handle = handle
end

Public Instance Methods

length(utf16=false) click to toggle source
# File lib/sqlite3/value.rb, line 21
def length(utf16=false)
  if utf16
    Driver.sqlite3_value_bytes16(@handle)
  else
    Driver.sqlite3_value_bytes(@handle)
  end
end
Also aliased as: size
native() click to toggle source
# File lib/sqlite3/value.rb, line 61
def native
  case Driver.sqlite3_value_type(@handle)
  when SQLITE_INTEGER then to_int64
  when SQLITE_FLOAT   then to_f
  when SQLITE_TEXT    then to_s
  when SQLITE_BLOB    then to_blob
  when SQLITE_NULL    then nil
  end
end
null?() click to toggle source
# File lib/sqlite3/value.rb, line 12
def null?
  type == :null
end
size(utf16=false)
Alias for: length
to_blob() click to toggle source
# File lib/sqlite3/value.rb, line 16
def to_blob
  bytes = size
  Blob.new(Driver.sqlite3_value_blob(@handle).to_s(bytes))
end
to_f() click to toggle source
# File lib/sqlite3/value.rb, line 31
def to_f
  Driver.sqlite3_value_double(@handle)
end
to_i() click to toggle source
# File lib/sqlite3/value.rb, line 35
def to_i
  Driver.sqlite3_value_int(@handle)
end
to_int64() click to toggle source
# File lib/sqlite3/value.rb, line 39
def to_int64
  Driver.sqlite3_value_int64(@handle)
end
to_s(utf16=false) click to toggle source
# File lib/sqlite3/value.rb, line 43
def to_s(utf16=false)
  if utf16
    Driver.sqlite3_result_text16(@handle).to_s
  else
    Driver.sqlite3_value_text(@handle).to_s
  end
end
type() click to toggle source
# File lib/sqlite3/value.rb, line 51
def type
  case Driver.sqlite3_value_type(@handle)
    when SQLITE_INTEGER then :int
    when SQLITE_FLOAT   then :float
    when SQLITE_TEXT    then :text
    when SQLITE_BLOB    then :blob
    when SQLITE_NULL    then :null
  end
end