lib/vertica/result.rb in vertica-0.11.4 vs lib/vertica/result.rb in vertica-0.12.0
- old
+ new
@@ -1,8 +1,8 @@
class Vertica::Result
include Enumerable
-
+
attr_reader :columns
attr_reader :rows
attr_accessor :tag, :notice
def initialize(row_style = :hash)
@@ -15,24 +15,24 @@
end
def format_row_as_hash(row_data)
row = {}
row_data.values.each_with_index do |value, idx|
- col = columns[idx]
+ col = columns.fetch(idx)
row[col.name] = col.convert(value)
end
row
end
-
+
def format_row(row_data)
send("format_row_as_#{@row_style}", row_data)
end
-
+
def format_row_as_array(row_data)
row = []
row_data.values.each_with_index do |value, idx|
- row << columns[idx].convert(value)
+ row << columns.fetch(idx).convert(value)
end
row
end
def add_row(row)
@@ -40,15 +40,15 @@
end
def each_row(&block)
@rows.each(&block)
end
-
+
def empty?
@rows.empty?
end
-
+
def the_value
if empty?
nil
else
@row_style == :array ? rows[0][0] : rows[0][columns[0].name]
@@ -56,10 +56,10 @@
end
def [](row, col = nil)
col.nil? ? row[row] : rows[row][col]
end
-
+
alias_method :each, :each_row
def row_count
@rows.size
end