Class: SQLite3::Value
- Inherits:
-
Object
- Object
- SQLite3::Value
- Defined in:
- lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb,
lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/value.rb
Instance Attribute Summary collapse
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
Instance Method Summary collapse
-
#initialize(db, handle) ⇒ Value
constructor
A new instance of Value.
- #length(utf16 = false) ⇒ Object
- #null? ⇒ Boolean
- #to_blob ⇒ Object
- #to_f ⇒ Object
- #to_i ⇒ Object
- #to_int64 ⇒ Object
- #to_s(utf16 = false) ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(db, handle) ⇒ Value
Returns a new instance of Value.
8 9 10 11 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb', line 8 def initialize( db, handle ) @driver = db.driver @handle = handle end |
Instance Attribute Details
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
6 7 8 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb', line 6 def handle @handle end |
Instance Method Details
#length(utf16 = false) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb', line 21 def length( utf16=false ) if utf16 @driver.value_bytes16( @handle ) else @driver.value_bytes( @handle ) end end |
#null? ⇒ Boolean
13 14 15 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb', line 13 def null? type == :null end |
#to_blob ⇒ Object
17 18 19 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb', line 17 def to_blob @driver.value_blob( @handle ) end |
#to_f ⇒ Object
29 30 31 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb', line 29 def to_f @driver.value_double( @handle ) end |
#to_i ⇒ Object
33 34 35 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb', line 33 def to_i @driver.value_int( @handle ) end |
#to_int64 ⇒ Object
37 38 39 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb', line 37 def to_int64 @driver.value_int64( @handle ) end |
#to_s(utf16 = false) ⇒ Object
41 42 43 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb', line 41 def to_s( utf16=false ) @driver.value_text( @handle, utf16 ) end |
#type ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb', line 45 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 |