Class: Cuker::CsvFile
- Inherits:
-
AbstractFile
- Object
- AbstractFile
- Cuker::CsvFile
- Defined in:
- lib/cuker/helpers/writers/csv_writer.rb
Overview
href="https://docs.ruby-lang.org/en/2.1.0/CSV.html">docs.ruby-lang.org/en/2.1.0/CSV.html CSV usage documentation
Instance Attribute Summary
Attributes inherited from AbstractFile
Attributes included from LoggerSetup
Instance Method Summary collapse
- #add_row(row_ary) ⇒ Object
-
#initialize(file_name) ⇒ CsvFile
constructor
A new instance of CsvFile.
-
#read_rows ⇒ Object
Ary of rows.
Methods inherited from AbstractFile
Methods included from LoggerSetup
#init_logger, reset_appender_log_levels
Constructor Details
#initialize(file_name) ⇒ CsvFile
Returns a new instance of CsvFile.
44 45 46 47 48 49 |
# File 'lib/cuker/helpers/writers/csv_writer.rb', line 44 def initialize file_name super file_name @log.debug "Making new #{self.class} => #{file_name}" @csv_sheet = CSV.open(file_name, "wb") @csv_sheet.close end |
Instance Method Details
#add_row(row_ary) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/cuker/helpers/writers/csv_writer.rb', line 51 def add_row row_ary super row_ary @log.warn "argument not an array.. instead is a '#{row_ary.class}' -> '#{row_ary}'" unless row_ary.is_a? Array CSV.open(@name, "ab") do |csv| csv << row_ary end end |
#read_rows ⇒ Object
Returns ary of rows.
60 61 62 |
# File 'lib/cuker/helpers/writers/csv_writer.rb', line 60 def read_rows @rows = CSV.read(@name) end |