123456789_123456789_123456789_123456789_123456789_

Class: SQLite3::Value

Relationships & Source Files
Inherits: Object
Defined in: lib/sqlite3/value.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(db, handle) ⇒ Value

[ GitHub ]

  
# File 'lib/sqlite3/value.rb', line 7

def initialize(db, handle)
  @driver = db.driver
  @handle = handle
end

Instance Attribute Details

#handle (readonly)

[ GitHub ]

  
# File 'lib/sqlite3/value.rb', line 5

attr_reader :handle

#null?Boolean (readonly)

[ GitHub ]

  
# File 'lib/sqlite3/value.rb', line 12

def null?
  type == :null
end

Instance Method Details

#length(utf16 = false)

[ GitHub ]

  
# File 'lib/sqlite3/value.rb', line 20

def length(utf16 = false)
  if utf16
    @driver.value_bytes16(@handle)
  else
    @driver.value_bytes(@handle)
  end
end

#to_blob

[ GitHub ]

  
# File 'lib/sqlite3/value.rb', line 16

def to_blob
  @driver.value_blob(@handle)
end

#to_f

[ GitHub ]

  
# File 'lib/sqlite3/value.rb', line 28

def to_f
  @driver.value_double(@handle)
end

#to_i

[ GitHub ]

  
# File 'lib/sqlite3/value.rb', line 32

def to_i
  @driver.value_int(@handle)
end

#to_int64

[ GitHub ]

  
# File 'lib/sqlite3/value.rb', line 36

def to_int64
  @driver.value_int64(@handle)
end

#to_s(utf16 = false)

[ GitHub ]

  
# File 'lib/sqlite3/value.rb', line 40

def to_s(utf16 = false)
  @driver.value_text(@handle, utf16)
end

#type

[ GitHub ]

  
# File 'lib/sqlite3/value.rb', line 44

def type
  case @driver.value_type(@handle)
  when Constants::ColumnType::INTEGER then :int
  when Constants::ColumnType::FLOAT then :float
  when Constants::ColumnType::TEXT then :text
  when Constants::ColumnType::BLOB then :blob
  when Constants::ColumnType::NULL then :null
  end
end