Class: RuboCop::Cop::Utils::RegexpRanges

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ RegexpRanges

Returns a new instance of RegexpRanges.



11
12
13
14
15
16
# File 'lib/rubocop/cop/utils/regexp_ranges.rb', line 11

def initialize(root)
  @root = root
  @compound_token = []
  @pairs = []
  @populated = false
end

Instance Attribute Details

#rootObject (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

#compound_tokenObject



18
19
20
21
22
# File 'lib/rubocop/cop/utils/regexp_ranges.rb', line 18

def compound_token
  populate_all unless @populated

  @compound_token
end

#pairsObject



24
25
26
27
28
# File 'lib/rubocop/cop/utils/regexp_ranges.rb', line 24

def pairs
  populate_all unless @populated

  @pairs
end