Sha256: ebe6763dc946442b47f981e654f3d42c0a3be6ebdec89a552cfc98fc9bdbe5d8

Contents?: true

Size: 624 Bytes

Versions: 1

Compression:

Stored size: 624 Bytes

Contents

class FixedWidthGenerator
  class Generator

    def initialize(definition)
      @definition = definition
    end

    def generate(data)
      @builder = []
      @definition.sections.each do |section|
        content = data[section.name]
        arrayed_content = content.is_a?(Array) ? content : [content]
        raise FixedWidthGenerator::RequiredSectionEmptyError.new("Required section '#{section.name}' was empty.") if (content.nil? || content.empty?) && !section.optional
        arrayed_content.each {|row| @builder << section.format(row) }
      end
      @builder.join("\n")
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aba_generator-1.0.0 lib/aba_generator/fixed_width/generator.rb