Class: AbstractWriter
- Inherits:
-
Object
- Object
- AbstractWriter
- Includes:
- IWriter, LoggerSetup
- Defined in:
- lib/cuker/writer_helper/abstract_writer.rb
Direct Known Subclasses
Constant Summary collapse
- NoNewFileMadeError =
Class.new IOError
Instance Attribute Summary collapse
-
#active_sheet ⇒ Object
Returns the value of attribute active_sheet.
-
#ext ⇒ Object
Returns the value of attribute ext.
-
#out_dir ⇒ Object
readonly
Returns the value of attribute out_dir.
-
#sheets ⇒ Object
Returns the value of attribute sheets.
Attributes included from LoggerSetup
Instance Method Summary collapse
-
#initialize ⇒ AbstractWriter
constructor
A new instance of AbstractWriter.
- #make_file(name) ⇒ Object
- #make_new_sheet(name = nil) ⇒ Object
- #raise_unless_active_loc(data) ⇒ Object
- #write_new_row(data) ⇒ Object
- #write_title(data) ⇒ Object
Methods included from LoggerSetup
#init_logger, reset_appender_log_levels
Methods included from Interface
Constructor Details
#initialize ⇒ AbstractWriter
21 22 23 24 25 26 27 28 |
# File 'lib/cuker/writer_helper/abstract_writer.rb', line 21 def initialize init_logger # @out_dir = output_path # FileUtils.mkdir_p(output_path) unless Dir.exist? output_path @log.debug "initing AbstractWriter" @active_sheet = nil @sheets = {} end |
Instance Attribute Details
#active_sheet ⇒ Object
Returns the value of attribute active_sheet.
18 19 20 |
# File 'lib/cuker/writer_helper/abstract_writer.rb', line 18 def active_sheet @active_sheet end |
#ext ⇒ Object
Returns the value of attribute ext.
17 18 19 |
# File 'lib/cuker/writer_helper/abstract_writer.rb', line 17 def ext @ext end |
#out_dir ⇒ Object (readonly)
Returns the value of attribute out_dir.
19 20 21 |
# File 'lib/cuker/writer_helper/abstract_writer.rb', line 19 def out_dir @out_dir end |
#sheets ⇒ Object
Returns the value of attribute sheets.
18 19 20 |
# File 'lib/cuker/writer_helper/abstract_writer.rb', line 18 def sheets @sheets end |
Instance Method Details
#make_file(name) ⇒ Object
49 50 51 |
# File 'lib/cuker/writer_helper/abstract_writer.rb', line 49 def make_file name @log.debug "make a new abstract file: #{name}" end |
#make_new_sheet(name = nil) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/cuker/writer_helper/abstract_writer.rb', line 42 def make_new_sheet name = nil file_name = name.nil? ? "Sheet_#{@sheets.size + 1}" : name @log.debug "make a new abstract sheet: #{file_name}" file_name # todo: file name collision handle end |
#raise_unless_active_loc(data) ⇒ Object
38 39 40 |
# File 'lib/cuker/writer_helper/abstract_writer.rb', line 38 def raise_unless_active_loc data raise NoNewFileMadeError.new "Please run 'make_file' before trying to write: '#{data}'" if @active_sheet.nil? end |
#write_new_row(data) ⇒ Object
34 35 36 |
# File 'lib/cuker/writer_helper/abstract_writer.rb', line 34 def write_new_row data raise_unless_active_loc data end |
#write_title(data) ⇒ Object
30 31 32 |
# File 'lib/cuker/writer_helper/abstract_writer.rb', line 30 def write_title data raise_unless_active_loc data end |