Class: Turso::Row
Instance Method Summary collapse
- #[](key) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(values, column_names) ⇒ Row
constructor
A new instance of Row.
- #length ⇒ Object (also: #size)
- #to_a ⇒ Object
Constructor Details
#initialize(values, column_names) ⇒ Row
Returns a new instance of Row.
7 8 9 10 |
# File 'lib/turso/row.rb', line 7 def initialize(values, column_names) @values = values @column_names = column_names end |
Instance Method Details
#[](key) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/turso/row.rb', line 16 def [](key) case key when Integer @values[key] when String, Symbol @values[column_index(key.to_s)] else raise ArgumentError, "invalid key type: #{key.class}" end end |
#each(&block) ⇒ Object
27 28 29 |
# File 'lib/turso/row.rb', line 27 def each(&block) @values.each(&block) end |
#length ⇒ Object Also known as: size
31 32 33 |
# File 'lib/turso/row.rb', line 31 def length @values.length end |
#to_a ⇒ Object
12 13 14 |
# File 'lib/turso/row.rb', line 12 def to_a @values.dup end |