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(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
141 142 |
# File 'lib/fileconv/base.rb', line 141 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
119 120 121 |
# File 'lib/fileconv/base.rb', line 119 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
110 111 112 |
# File 'lib/fileconv/base.rb', line 110 def convert_line(line, acc) line end |
#init_acc(acc) ⇒ void
This method returns an undefined value.
Init a accumlator
95 96 |
# File 'lib/fileconv/base.rb', line 95 def init_acc(acc) end |
#init_conv ⇒ void
This method returns an undefined value.
Initialize the convertor
89 90 |
# File 'lib/fileconv/base.rb', line 89 def init_conv end |
#input_dir ⇒ String
Input Directory
62 63 64 |
# File 'lib/fileconv/base.rb', line 62 def input_dir @opts[:input_dir] || "." end |
#input_ext ⇒ String?
target all files if this method return nil
File extention for input file
69 70 71 |
# File 'lib/fileconv/base.rb', line 69 def input_ext @opts[:input_ext] end |
#input_files(files) ⇒ Array<String>
you can overwrite default input files
Input files
83 84 85 |
# File 'lib/fileconv/base.rb', line 83 def input_files(files) files end |
#output_dir ⇒ String
Output Directory
75 76 77 |
# File 'lib/fileconv/base.rb', line 75 def output_dir @opts[:output_dir] || "output" end |
#output_filename(filename, acc) ⇒ String
File name for the output
127 128 129 |
# File 'lib/fileconv/base.rb', line 127 def output_filename(filename, acc) filename end |
#read_file(filename, acc) ⇒ Object?
use default reader if this method return nil
Read a file
102 103 |
# File 'lib/fileconv/base.rb', line 102 def read_file(filename, acc) end |
#result_filename ⇒ String
File name for the result
133 134 135 |
# File 'lib/fileconv/base.rb', line 133 def result_filename @opts[:result_file] || "result.txt" end |