lib/masticate/base.rb in masticate-0.1.5 vs lib/masticate/base.rb in masticate-0.2

- old
+ new

@@ -2,12 +2,19 @@ attr_reader :filename attr_reader :input, :output attr_reader :input_count, :output_count attr_reader :csv_options - def initialize(filename) - @filename = filename + def initialize(args) + case args + when String + @filename = args + when Hash + configure(args) + else + raise "invalid initialization: #{args}" + end end def with_input @input = @filename ? open(@filename) : $stdin @input_count = 0 @@ -38,6 +45,10 @@ @csv_options[:col_sep] = opts[:col_sep] if opts[:col_sep] if opts[:col_sep] @csv_options[:quote_char] = opts[:quote_char] || "\0" end end + + # def crunch(row) + # # noop + # end end