class TableSyntax::HeaderTable
Public Class Methods
new(headers, table)
click to toggle source
# File lib/table_syntax/header_table.rb, line 5 def initialize(headers, table) unless headers.all? {|h| h.kind_of?(Symbol) } raise ArgumentError, "All headers must be symbols" end @struct = Struct.new(*headers) @rows = table.to_a end
Public Instance Methods
each() { |struct(*row)| ... }
click to toggle source
# File lib/table_syntax/header_table.rb, line 13 def each return enum_for(:each) unless block_given? @rows.each do |row| yield @struct.new(*row) end end