Class: Tina4::GraphResult
- Inherits:
-
Object
- Object
- Tina4::GraphResult
- Includes:
- Enumerable
- Defined in:
- lib/tina4/graph.rb
Overview
A raw-query result — records + columns, same shape as DatabaseResult.
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(records: nil, columns: nil) ⇒ GraphResult
constructor
A new instance of GraphResult.
- #length ⇒ Object (also: #size)
- #scalar ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(records: nil, columns: nil) ⇒ GraphResult
Returns a new instance of GraphResult.
170 171 172 173 |
# File 'lib/tina4/graph.rb', line 170 def initialize(records: nil, columns: nil) @records = records || [] @columns = columns || [] end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
168 169 170 |
# File 'lib/tina4/graph.rb', line 168 def columns @columns end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
168 169 170 |
# File 'lib/tina4/graph.rb', line 168 def records @records end |
Instance Method Details
#each(&block) ⇒ Object
192 193 194 |
# File 'lib/tina4/graph.rb', line 192 def each(&block) @records.each(&block) end |
#length ⇒ Object Also known as: size
196 197 198 |
# File 'lib/tina4/graph.rb', line 196 def length @records.length end |
#scalar ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/tina4/graph.rb', line 179 def scalar return nil if @records.empty? first = @records[0] if first.is_a?(Hash) first.values.first elsif first.is_a?(Array) first.empty? ? nil : first[0] else first end end |
#to_a ⇒ Object
175 176 177 |
# File 'lib/tina4/graph.rb', line 175 def to_a @records end |