Sha256: fea04c3f196215cd034a1e43e97939bfd5834a6dc2092ad1098aa2a764c52b64

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

module CommaPile
  class Config
    def initialize
      @field_names = []
      @sum = []
    end
    attr_writer :conditions, :input, :output, :line_parser

    def sum_on; @sum; end
    def sum_on=(value)
      @sum = (@sum << value).flatten.uniq
    end

    def line_parser
      @line_parser ||= CommaPile::LineParser
      if @line_parser.respond_to?(:with) && @line_parser.method(:with).arity == 1
        @line_parser
      else
        raise RuntimeError, "#{self.class.to_s}#line_parser must respond to :with and have an arity of 1.  The line parser will receive an array of fields"
      end
    end

    def output; @output; end
    
    def input; @input || './file.csv'; end
    alias_method :source, :input
    alias_method :source=, :input=
    
    def conditions; @conditions; end
    
    def field_names; @field_names; end
    def field_names=(value)
      @field_names = (@field_names << value).flatten.uniq
    end
    
    alias_method :on, :field_names
    alias_method :on=, :field_names=
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jeremyf-comma_pile-0.1.0 lib/comma_pile/config.rb
jeremyf-comma_pile-0.1.1 lib/comma_pile/config.rb
jeremyf-comma_pile-0.1.2 lib/comma_pile/config.rb