Class: Neo4j::Core::CypherSession::Result
- Inherits:
-
Object
- Object
- Neo4j::Core::CypherSession::Result
- Includes:
- Enumerable
- Defined in:
- lib/neo4j/core/cypher_session/result.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #each ⇒ Object
- #hashes ⇒ Object
-
#initialize(columns, rows) ⇒ Result
constructor
A new instance of Result.
- #structs ⇒ Object
Constructor Details
#initialize(columns, rows) ⇒ Result
Returns a new instance of Result.
11 12 13 14 15 |
# File 'lib/neo4j/core/cypher_session/result.rb', line 11 def initialize(columns, rows) @columns = columns.map(&:to_sym) @rows = rows @struct_class = Struct.new(:index, *@columns) end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
9 10 11 |
# File 'lib/neo4j/core/cypher_session/result.rb', line 9 def columns @columns end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
9 10 11 |
# File 'lib/neo4j/core/cypher_session/result.rb', line 9 def rows @rows end |
Instance Method Details
#each ⇒ Object
19 20 21 22 23 |
# File 'lib/neo4j/core/cypher_session/result.rb', line 19 def each structs.each do |struct| yield struct end end |
#hashes ⇒ Object
31 32 33 34 35 |
# File 'lib/neo4j/core/cypher_session/result.rb', line 31 def hashes @hashes ||= rows.map do |row| Hash[@columns.zip(row)] end end |
#structs ⇒ Object
25 26 27 28 29 |
# File 'lib/neo4j/core/cypher_session/result.rb', line 25 def structs @structs ||= rows.each_with_index.map do |row, index| @struct_class.new(index, *row) end end |