Sha256: 6b651a111ae569dfb01c598c38870aee80f541a5d01e43a74f3138b23c6a19f8

Contents?: true

Size: 868 Bytes

Versions: 4

Compression:

Stored size: 868 Bytes

Contents

class FixedWidth
  class Definition
    attr_reader :sections, :templates, :options

    def initialize(options={})
      @sections  = []
      @templates = {}
      @options   = { :align => :right }.merge(options)
    end

    def section(name, options={}, &block)
      raise DuplicateSectionNameError.new("Duplicate section name: '#{name}'") if @sections.detect{|s| s.name == name }

      section = FixedWidth::Section.new(name, @options.merge(options))
      section.definition = self
      yield(section)
      @sections << section
      section
    end

    def template(name, options={}, &block)
      section = FixedWidth::Section.new(name, @options.merge(options))
      yield(section)
      @templates[name] = section
    end

    def method_missing(method, *args, &block)
      section(method, *args, &block)
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
fixed_width-multibyte-0.2.3 lib/fixed_width/definition.rb
fixed_width-multibyte-0.2.2 lib/fixed_width/definition.rb
fixed_width-0.2.1 lib/fixed_width/definition.rb
fixed_width-0.2.0 lib/fixed_width/definition.rb