Class: TableStructure::Writer
- Inherits:
-
Object
- Object
- TableStructure::Writer
- Defined in:
- lib/table_structure/writer.rb
Defined Under Namespace
Classes: Output
Instance Method Summary collapse
-
#initialize(schema, header: { context: nil, step: nil }, method: :<<, row_type: :array) ⇒ Writer
constructor
A new instance of Writer.
- #write(items, to:, method: @options[:method], &block) ⇒ Object
Constructor Details
#initialize(schema, header: { context: nil, step: nil }, method: :<<, row_type: :array) ⇒ Writer
Returns a new instance of Writer.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/table_structure/writer.rb', line 5 def initialize( schema, header: { context: nil, step: nil }, method: :<<, row_type: :array ) @schema = schema = { header: header, method: method, row_type: row_type } end |
Instance Method Details
#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: [:method], &block ) output = Output.new(to, method: method) Iterator .new( @schema, header: [:header], row_type: [:row_type] ) .iterate(items, &block) .each { |row| output.write(row) } nil end |