class Emmental
Constants
- VERSION
Attributes
headers[RW]
rows[R]
Public Class Methods
new(headers=[])
click to toggle source
# File lib/emmental.rb, line 11 def initialize(headers=[]) @headers = Emmental::Headers.new(headers) @rows = [] end
Public Instance Methods
add_row(hash)
click to toggle source
# File lib/emmental.rb, line 20 def add_row(hash) @rows << Emmental::Row.new(hash, @headers) end
Also aliased as: <<
each() { |row| ... }
click to toggle source
# File lib/emmental.rb, line 16 def each @rows.each{|row| yield(row) } end
to_a(options={})
click to toggle source
# File lib/emmental.rb, line 25 def to_a(options={}) array = (options[:headers] == false) ? [] : [@headers] @rows.each do |row| array << @headers.map{|header| row.to_h[header] } end array end