Module: Fileconv::Convertor
- Included in:
- Base
- Defined in:
- lib/fileconv/base.rb
Instance Method Summary collapse
-
#conv_result ⇒ String?
Conversion result.
-
#convert_file(file, acc) ⇒ String?
Convert a File.
-
#convert_line(line, acc) ⇒ Object, ...
Convert a Line.
-
#init_acc(acc) ⇒ void
Init a accumlator.
-
#init_conv ⇒ void
Initialize the convertor.
-
#input_dir ⇒ String
Input Directory.
-
#input_ext ⇒ String?
File extention for input file.
-
#input_files ⇒ Array<String>?
Input files.
-
#output_dir ⇒ String
Output Directory.
-
#output_filename(filename, acc) ⇒ String
File name for the output.
-
#read_file(filename, acc) ⇒ Object?
Read a file.
-
#result_filename ⇒ String
File name for the result.
Instance Method Details
#conv_result ⇒ String?
output the string result to a file(#result_filename) and don’t create file if this method return nil(default)
you can create result data using @meta or anather instance variable you create
Conversion result
130 131 |
# File 'lib/fileconv/base.rb', line 130 def conv_result end |
#convert_file(file, acc) ⇒ String?
output the string to a file(#output_filename) and don’t create file if this method return nil
Convert a File
108 109 110 |
# File 'lib/fileconv/base.rb', line 108 def convert_file(file, acc) file end |
#convert_line(line, acc) ⇒ Object, ...
add the line object add all lines if this method return Array and don’t add it if this method return nil
Convert a Line
99 100 101 |
# File 'lib/fileconv/base.rb', line 99 def convert_line(line, acc) line end |
#init_acc(acc) ⇒ void
This method returns an undefined value.
Init a accumlator
84 85 |
# File 'lib/fileconv/base.rb', line 84 def init_acc(acc) end |
#init_conv ⇒ void
This method returns an undefined value.
Initialize the convertor
78 79 |
# File 'lib/fileconv/base.rb', line 78 def init_conv end |
#input_dir ⇒ String
Input Directory
52 53 54 |
# File 'lib/fileconv/base.rb', line 52 def input_dir @opts[:input_dir] || "." end |
#input_ext ⇒ String?
target all files if this method return nil
File extention for input file
59 60 61 |
# File 'lib/fileconv/base.rb', line 59 def input_ext @opts[:input_ext] end |
#input_files ⇒ Array<String>?
ignore #input_dir if this method return non-nil
select files by #input_dir and #input_ext if this method return nil
Input files
73 74 |
# File 'lib/fileconv/base.rb', line 73 def input_files end |
#output_dir ⇒ String
Output Directory
65 66 67 |
# File 'lib/fileconv/base.rb', line 65 def output_dir @opts[:output_dir] || "output" end |
#output_filename(filename, acc) ⇒ String
File name for the output
116 117 118 |
# File 'lib/fileconv/base.rb', line 116 def output_filename(filename, acc) filename end |
#read_file(filename, acc) ⇒ Object?
use default reader if this method return nil
Read a file
91 92 |
# File 'lib/fileconv/base.rb', line 91 def read_file(filename, acc) end |
#result_filename ⇒ String
File name for the result
122 123 124 |
# File 'lib/fileconv/base.rb', line 122 def result_filename @opts[:result_file] || "result.txt" end |