Skip to content

Commit

Permalink
Fix ivar warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jaynetics committed Feb 27, 2023
1 parent 777ac8c commit d9dfe5b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions lib/regexp_parser/expression/quantifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ def deprecated_old_init(token, text, _min, _max, _mode = :greedy)
end

def derived_data
return @derived_data if @derived_data
@derived_data ||= begin
min, max =
case text[0]
when '?'; [0, 1]
when '*'; [0, -1]
when '+'; [1, -1]
else
int_min = text[/\{(\d*)/, 1]
int_max = text[/,?(\d*)\}/, 1]
[int_min.to_i, (int_max.empty? ? -1 : int_max.to_i)]
end

min, max =
case text[0]
when '?'; [0, 1]
when '*'; [0, -1]
when '+'; [1, -1]
else
int_min = text[/\{(\d*)/, 1]
int_max = text[/,?(\d*)\}/, 1]
[int_min.to_i, (int_max.empty? ? -1 : int_max.to_i)]
end

mod = text[/.([?+])/, 1]
mode = (mod == '?' && :reluctant) || (mod == '+' && :possessive) || :greedy
mod = text[/.([?+])/, 1]
mode = (mod == '?' && :reluctant) || (mod == '+' && :possessive) || :greedy

@derived_data = { min: min, max: max, mode: mode }
{ min: min, max: max, mode: mode }
end
end
end
end

0 comments on commit d9dfe5b

Please sign in to comment.