Method: TableStructure::Writer#write

Defined in:
lib/table_structure/writer.rb

#write(items, to:, method: @options[:method], &block) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/table_structure/writer.rb', line 19

def write(
  items,
  to:,
  method: @options[:method],
  &block
)
  output = Output.new(to, method: method)

  Iterator
    .new(
      @schema,
      header: @options[:header],
      row_type: @options[:row_type]
    )
    .iterate(items, &block)
    .each { |row| output.write(row) }

  nil
end