@@ -50,6 +50,14 @@ class SymbolArray < Base
50
50
PERCENT_MSG = 'Use `%i` or `%I` for an array of symbols.'
51
51
ARRAY_MSG = 'Use %<prefer>s for an array of symbols.'
52
52
DELIMITERS = [ '[' , ']' , '(' , ')' ] . freeze
53
+ SPECIAL_GVARS = %w[
54
+ $! $" $$ $& $' $* $+ $, $/ $; $: $. $< $= $> $? $@ $\\ $_ $` $~ $0
55
+ $-0 $-F $-I $-K $-W $-a $-d $-i $-l $-p $-v $-w
56
+ ] . freeze
57
+ REDEFINABLE_OPERATORS = %w(
58
+ | ^ & <=> == === =~ > >= < <= << >>
59
+ + - * / % ** ~ +@ -@ [] []= ` ! != !~
60
+ ) . freeze
53
61
54
62
class << self
55
63
attr_accessor :largest_brackets
@@ -109,24 +117,15 @@ def to_symbol_literal(string)
109
117
end
110
118
111
119
def symbol_without_quote? ( string )
112
- special_gvars = %w[
113
- $! $" $$ $& $' $* $+ $, $/ $; $: $. $< $= $> $? $@ $\\ $_ $` $~ $0
114
- $-0 $-F $-I $-K $-W $-a $-d $-i $-l $-p $-v $-w
115
- ]
116
- redefinable_operators = %w(
117
- | ^ & <=> == === =~ > >= < <= << >>
118
- + - * / % ** ~ +@ -@ [] []= ` ! != !~
119
- )
120
-
121
120
# method name
122
121
/\A [a-zA-Z_]\w *[!?]?\z / . match? ( string ) ||
123
122
# instance / class variable
124
123
/\A @@?[a-zA-Z_]\w *\z / . match? ( string ) ||
125
124
# global variable
126
125
/\A \$ [1-9]\d *\z / . match? ( string ) ||
127
126
/\A \$ [a-zA-Z_]\w *\z / . match? ( string ) ||
128
- special_gvars . include? ( string ) ||
129
- redefinable_operators . include? ( string )
127
+ SPECIAL_GVARS . include? ( string ) ||
128
+ REDEFINABLE_OPERATORS . include? ( string )
130
129
end
131
130
end
132
131
end
0 commit comments