lib/masticate/base.rb in masticate-0.1.0 vs lib/masticate/base.rb in masticate-0.1.1
- old
+ new
@@ -1,9 +1,10 @@
class Masticate::Base
attr_reader :filename
attr_reader :input, :output
attr_reader :input_count, :output_count
+ attr_reader :csv_options
def initialize(filename)
@filename = filename
end
@@ -26,8 +27,17 @@
begin
@output.puts line
rescue Errno::EPIPE
# output was closed, e.g. ran piped into `head`
# silently ignore this condition, it's not fatal and doesn't need a warning
+ end
+ end
+
+ def standard_options(opts)
+ @output = opts[:output] ? File.open(opts[:output], "w") : $stdout
+ @csv_options = {}
+ @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
end