Sha256: 35ba74474e34c7ae298c3ac0928cef8f844e3a5be3debcb3893f2bd4de2d00d4
Contents?: true
Size: 641 Bytes
Versions: 5
Compression:
Stored size: 641 Bytes
Contents
module ActiveGraph module Core class Result attr_reader :columns, :rows def initialize(columns, rows) @columns = columns.map(&:to_sym) @rows = rows @struct_class = Struct.new(:index, *@columns) end include Enumerable def each structs.each do |struct| yield struct end end def structs @structs ||= rows.each_with_index.map do |row, index| @struct_class.new(index, *row) end end def hashes @hashes ||= rows.map do |row| Hash[@columns.zip(row)] end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems