Class: Neo4j::Driver::Record
- Inherits:
-
Object
- Object
- Neo4j::Driver::Record
- Defined in:
- lib/neo4j/driver/record.rb
Overview
Represents a single record (row) in a result
Instance Attribute Summary collapse
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #each ⇒ Object
- #first ⇒ Object
-
#initialize(keys, values) ⇒ Record
constructor
A new instance of Record.
- #to_h ⇒ Object
Constructor Details
#initialize(keys, values) ⇒ Record
Returns a new instance of Record.
7 8 9 10 11 12 13 14 15 |
# File 'lib/neo4j/driver/record.rb', line 7 def initialize(keys, values) @keys = keys @values = values # Create map with string keys for consistent lookup @map = {} @keys.each_with_index do |key, idx| @map[key.to_s] = @values[idx] end end |
Instance Attribute Details
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
17 18 19 |
# File 'lib/neo4j/driver/record.rb', line 17 def keys @keys end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
17 18 19 |
# File 'lib/neo4j/driver/record.rb', line 17 def values @values end |
Instance Method Details
#[](key) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/neo4j/driver/record.rb', line 19 def [](key) case key when Integer @values[key] when String, Symbol @map[key.to_s] else raise ArgumentError, "Invalid key type: #{key.class}" end end |
#each ⇒ Object
38 39 40 |
# File 'lib/neo4j/driver/record.rb', line 38 def each(&) @map.each(&) end |
#first ⇒ Object
30 31 32 |
# File 'lib/neo4j/driver/record.rb', line 30 def first @values.first end |
#to_h ⇒ Object
34 35 36 |
# File 'lib/neo4j/driver/record.rb', line 34 def to_h @map.dup end |