Class: RuboCop::Cop::Utils::RegexpRanges
- Inherits:
-
Object
- Object
- RuboCop::Cop::Utils::RegexpRanges
- Defined in:
- lib/rubocop/cop/utils/regexp_ranges.rb
Overview
Helper to abstract complexity of building range pairs with octal escape reconstruction (needed for regexp_parser < 2.7).
Instance Attribute Summary collapse
-
#compound_token ⇒ Object
readonly
Returns the value of attribute compound_token.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(root) ⇒ RegexpRanges
constructor
A new instance of RegexpRanges.
- #pairs ⇒ Object
Constructor Details
#initialize(root) ⇒ RegexpRanges
Returns a new instance of RegexpRanges.
11 12 13 14 |
# File 'lib/rubocop/cop/utils/regexp_ranges.rb', line 11 def initialize(root) @root = root @compound_token = [] end |
Instance Attribute Details
#compound_token ⇒ Object (readonly)
Returns the value of attribute compound_token.
9 10 11 |
# File 'lib/rubocop/cop/utils/regexp_ranges.rb', line 9 def compound_token @compound_token end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
9 10 11 |
# File 'lib/rubocop/cop/utils/regexp_ranges.rb', line 9 def root @root end |
Instance Method Details
#pairs ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubocop/cop/utils/regexp_ranges.rb', line 16 def pairs unless @pairs @pairs = [] populate(root) end # If either bound is a compound the first one is an escape # and that's all we need to work with. # If there are any cops that wanted to operate on the compound # expression we could wrap it with a facade class. @pairs.map { |pair| pair.map(&:first) } end |