Class: GaussianParser::Parser
- Inherits:
-
Object
- Object
- GaussianParser::Parser
show all
- Includes:
- Cli
- Defined in:
- lib/gaussian_parser/parser.rb
Constant Summary
Constants included
from Cli
Cli::ERROR_COLOR, Cli::SUCCESS_COLOR
Instance Method Summary
collapse
Methods included from Cli
#print_as_error, #print_as_success, #print_as_usual
Constructor Details
#initialize(argv = {}) ⇒ Parser
Returns a new instance of Parser.
8
9
10
11
|
# File 'lib/gaussian_parser/parser.rb', line 8
def initialize(argv = {})
@params = argv[:params] || {}
@options = argv[:options] || {}
end
|
Instance Method Details
#create_folder_if_not_exist(folder_path) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/gaussian_parser/parser.rb', line 21
def create_folder_if_not_exist folder_path
unless Dir.exist? folder_path
print_as_success("Creating #{folder_path}")
Dir.mkdir(folder_path)
end
folder_path
end
|
#get_file_path_from_current_dir(path) ⇒ Object
13
14
15
|
# File 'lib/gaussian_parser/parser.rb', line 13
def get_file_path_from_current_dir path
File.join(Dir.pwd, path)
end
|
#get_output_directory_path ⇒ Object
17
18
19
|
# File 'lib/gaussian_parser/parser.rb', line 17
def get_output_directory_path
get_file_path_from_current_dir("output")
end
|
#process ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/gaussian_parser/parser.rb', line 29
def process
if @params.length > 0
output_base_path = get_file_path_from_current_dir(create_folder_if_not_exist("output"))
@params.each do |file_name|
print_as_usual("Try to process #{file_name}")
if File.exist?(file_name)
base_file_name = File.basename(File.basename(file_name), ".out.txt")
file_output_folder = create_folder_if_not_exist(File.join(output_base_path, base_file_name))
params = {
output_path: file_output_folder,
file_name: file_name
}
FileItemProcessor.new(params).proccess
else
print_as_error("'#{file_name}' doesn't exist or it is not a valid file")
end
end
else
print_as_error("Unspecified input data")
end
end
|