-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.rb
46 lines (38 loc) · 1.02 KB
/
error.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# frozen_string_literal: true
# The new instance will be deleted after process ends.
class MiniTestFile
attr_reader :mini_test
# Default encoding utf8, Encoding change here.
def encoding_style
Encoding.default_internal = 'UTF-8'
Encoding.default_external = 'UTF-8'
end
def initialize
encoding_style
ja = 'ja'.to_s
en = 'en'.to_s
input = ARGV[0].to_s
output = /#{input}/o
if ARGV[0].nil?
@mini_test = require "#{File.dirname(__FILE__)}/error/error_en.rb"
elsif ja.match(output) || {}[:match]
@mini_test = require "#{File.dirname(__FILE__)}/error/error_ja.rb"
elsif en.match(output) || {}[:match]
@mini_test = require "#{File.dirname(__FILE__)}/error/error_en.rb"
else
@mini_test = puts 'Please enter ja or en as an argument.'
end
end
def remove
remove_instance_variable(:@mini_test)
end
end
# About Exception, begin ~ rescue ~ ensure.
begin
MiniTestFile.new.remove
rescue StandardError => e
puts e.backtrace
ensure
GC.compact
end
__END__