Class: Libsql::QueryResult
- Inherits:
-
Object
- Object
- Libsql::QueryResult
- Defined in:
- lib/libsql.rb
Instance Method Summary collapse
- #close ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(result) ⇒ QueryResult
constructor
A new instance of QueryResult.
- #to_a ⇒ Object
Constructor Details
#initialize(result) ⇒ QueryResult
Returns a new instance of QueryResult.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/libsql.rb', line 105 def initialize(result) @result = result # Extract columns and rows from Turso's format if @result["results"] && @result["results"][0] && @result["results"][0]["type"] == "ok" && @result["results"][0]["response"] && @result["results"][0]["response"]["type"] == "execute" && @result["results"][0]["response"]["result"] result_data = @result["results"][0]["response"]["result"] @columns = result_data["cols"] || [] @rows = result_data["rows"] || [] else @columns = [] @rows = [] end end |
Instance Method Details
#close ⇒ Object
133 134 135 |
# File 'lib/libsql.rb', line 133 def close # No-op for HTTP API end |
#empty? ⇒ Boolean
125 126 127 |
# File 'lib/libsql.rb', line 125 def empty? @rows.empty? end |
#to_a ⇒ Object
129 130 131 |
# File 'lib/libsql.rb', line 129 def to_a @rows end |