Class: Masticate::Csvify
Instance Attribute Summary
Attributes inherited from Base
#csv_options, #filename, #input, #input_count, #output, #output_count
Instance Method Summary collapse
- #csvify(opts) ⇒ Object
-
#initialize(filename) ⇒ Csvify
constructor
A new instance of Csvify.
Methods inherited from Base
#emit, #execute, #get, #standard_options, #with_input
Constructor Details
#initialize(filename) ⇒ Csvify
Returns a new instance of Csvify.
5 6 7 |
# File 'lib/masticate/csvify.rb', line 5 def initialize(filename) @filename = filename end |
Instance Method Details
#csvify(opts) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/masticate/csvify.rb', line 9 def csvify(opts) (opts) @output_count = 0 with_input do |input| while line = get row = CSV.parse_line(line, ) if row row = row.map {|s| s && s.strip} emit(row) end end end @output.close if opts[:output] { :input_count => input_count, :output_count => @output_count } end |