Sha256: 4f03381e478dbd401a7aa7752045fac52a5354b587232e11b23cc1f81e8ccd16
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
require 'csv' require 'riif/dsl/base' require 'riif/dsl/accnt' require 'riif/dsl/bud' require 'riif/dsl/ctype' require 'riif/dsl/cust' require 'riif/dsl/emp' require 'riif/dsl/invitem' require 'riif/dsl/invmemo' require 'riif/dsl/klass' require 'riif/dsl/othername' require 'riif/dsl/paymeth' require 'riif/dsl/shipmeth' require 'riif/dsl/spl' require 'riif/dsl/terms' require 'riif/dsl/timeact' require 'riif/dsl/timerhdr' require 'riif/dsl/trns' require 'riif/dsl/vend' require 'riif/dsl/vtype' module Riif class IIF def initialize(&block) @output = {} if block_given? instance_eval(&block) end end def output CSV.generate(col_sep: "\t") do |tsv| @output.each do |_, list| list[:headers].uniq.each do |header| tsv << header end list[:rows].each do |row| tsv << row end end end end def method_missing(method_name, *args, &block) result = eval("::Riif::DSL::#{method_name.capitalize}").new.build(&block) @output[method_name] ||= { headers: [], rows: [] } @output[method_name][:headers].concat(result[:headers]) @output[method_name][:rows].concat(result[:rows]) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
riif-0.5.0 | lib/riif/iif.rb |