Module: Eturem::ArgumentErrorExt
- Includes:
- ExceptionExt
- Defined in:
- lib/eturem/base.rb,
lib/eturem/ja/argument_error.rb
Instance Method Summary
collapse
#eturem_location_to_s, #eturem_traceback
Methods included from Base
after_line_num=, before_line_num=, #eturem_backtrace, #eturem_backtrace_locations, #eturem_backtrace_str, #eturem_full_message, #eturem_location_to_s, #eturem_original_error_message, #eturem_script, highlight, output_backtrace=, output_original=, output_script=, read_script, script, unhighlight, use_coderay=, warning_message
Instance Method Details
#eturem_argument_too_big ⇒ Object
48
49
50
|
# File 'lib/eturem/ja/argument_error.rb', line 48
def eturem_argument_too_big()
@eturem_message_ja = "「#{@eturem_method}」への引数が大きすぎます。"
end
|
#eturem_message ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/eturem/ja/argument_error.rb', line 7
def eturem_message()
given = nil
if @eturem_message.include?("wrong number of arguments")
if @eturem_message.match(/\(given (?<given>\d+), expected (?<expected>[^)]+)\)/)
given = Regexp.last_match(:given).to_i
expected = Regexp.last_match(:expected)
elsif @eturem_message.match(/\((?<given>\d+) for (?<expected>[^)]+)\)/)
given = Regexp.last_match(:given).to_i
expected = Regexp.last_match(:expected)
end
end
if given
eturem_wrong_number_of_arguments(given, expected)
elsif @eturem_message.match(/too big/)
eturem_argument_too_big
else
eturem_other_argument_error
end
super
end
|
#eturem_other_argument_error ⇒ Object
52
53
54
|
# File 'lib/eturem/ja/argument_error.rb', line 52
def eturem_other_argument_error()
@eturem_message_ja = "「#{@eturem_method}」への引数が正しくありません。"
end
|
#eturem_prepare ⇒ Object
291
292
293
294
295
296
297
|
# File 'lib/eturem/base.rb', line 291
def eturem_prepare()
super
@eturem_method = @eturem_label
eturem_backtrace_locations_shift
@eturem_script_lines = Eturem::Base.read_script(@eturem_path)
@eturem_output_linenos = eturem_default_output_linenos
end
|
#eturem_wrong_number_of_arguments(given, expected) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/eturem/ja/argument_error.rb', line 29
def eturem_wrong_number_of_arguments(given, expected)
@eturem_message_ja = "引数の数が正しくありません。「#{@eturem_method}」は本来"
case expected
when "0"
@eturem_message_ja += "引数が不要です"
when /^(\d+)\.\.(\d+)$/
@eturem_message_ja += " #{$1}~#{$2} 個の引数を取ります"
when /^(\d+)\+$/
@eturem_message_ja += " #{$1} 個以上の引数を取ります"
else
@eturem_message_ja += " #{expected} 個の引数を取ります"
end
if given == 0
@eturem_message_ja += "が、引数が1つも渡されていません。"
else
@eturem_message_ja += "が、#{given} 個の引数が渡されています。"
end
end
|