Class: Libsql::Rows
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
- #column_count ⇒ Object
- #columns ⇒ Object
- #each ⇒ Object
-
#initialize(inner) ⇒ Rows
constructor
A new instance of Rows.
- #next ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(inner) ⇒ Rows
Returns a new instance of Rows.
319 320 321 |
# File 'lib/libsql.rb', line 319 def initialize(inner) @inner = inner end |
Instance Method Details
#close ⇒ Object
353 354 355 356 357 358 |
# File 'lib/libsql.rb', line 353 def close raise ClosedException if closed? @inner.deinit @inner = nil end |
#closed? ⇒ Boolean
360 361 362 |
# File 'lib/libsql.rb', line 360 def closed? @inner.nil? end |
#column_count ⇒ Object
323 324 325 326 327 |
# File 'lib/libsql.rb', line 323 def column_count raise ClosedException if closed? @inner.length end |
#columns ⇒ Object
329 330 331 332 333 |
# File 'lib/libsql.rb', line 329 def columns raise ClosedException if closed? (0...column_count).map { |i| @inner.name_at(i).to_s } end |
#each ⇒ Object
346 347 348 349 350 351 |
# File 'lib/libsql.rb', line 346 def each while (row = self.next) yield row row.close end end |
#next ⇒ Object
339 340 341 342 343 344 |
# File 'lib/libsql.rb', line 339 def next raise ClosedException if closed? row = @inner.next Row.new row unless row.empty? end |
#to_a ⇒ Object
335 336 337 |
# File 'lib/libsql.rb', line 335 def to_a map(&:to_h) end |