123456789_123456789_123456789_123456789_123456789_

Class: Capybara::Selector::RegexpDisassembler::Expression Private

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: lib/capybara/selector/regexp_disassembler.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(exp) ⇒ Expression

[ GitHub ]

  
# File 'lib/capybara/selector/regexp_disassembler.rb', line 93

def initialize(exp)
  @exp = exp
end

Instance Attribute Details

#fixed_repeat?Boolean (readonly, private)

[ GitHub ]

  
# File 'lib/capybara/selector/regexp_disassembler.rb', line 180

def fixed_repeat?
  min_repeat == max_repeat
end

#indeterminate?Boolean (readonly, private)

[ GitHub ]

  
# File 'lib/capybara/selector/regexp_disassembler.rb', line 168

def indeterminate?
  %i[meta set].include?(type)
end

Instance Method Details

#alternatives (private)

[ GitHub ]

  
# File 'lib/capybara/selector/regexp_disassembler.rb', line 200

def alternatives
  @exp.alternatives.map { |exp| Expression.new(exp) }
end

#each (private)

[ GitHub ]

  
# File 'lib/capybara/selector/regexp_disassembler.rb', line 204

def each
  @exp.each { |exp| yield Expression.new(exp) }
end

#extract_strings(process_alternatives)

[ GitHub ]

  
# File 'lib/capybara/selector/regexp_disassembler.rb', line 97

def extract_strings(process_alternatives)
  strings = []
  each do |exp|
    next if exp.ignore?

    next strings.push(nil) if exp.optional? && !process_alternatives

    next strings.push(exp.alternative_strings) if exp.alternation? && process_alternatives

    strings.concat(exp.strings(process_alternatives))
  end
  strings
end

#max_repeat (private)

[ GitHub ]

  
# File 'lib/capybara/selector/regexp_disassembler.rb', line 176

def max_repeat
  @exp.repetitions.end
end

#min_repeat (private)

[ GitHub ]

  
# File 'lib/capybara/selector/regexp_disassembler.rb', line 172

def min_repeat
  @exp.repetitions.begin
end

#options_set(strs) (private)

[ GitHub ]

  
# File 'lib/capybara/selector/regexp_disassembler.rb', line 194

def options_set(strs)
  strs = [Set.new([[''], Array(strs)])]
  strs.push(nil) unless max_repeat == 1
  strs
end

#repeat_set(str) (private)

[ GitHub ]

  
# File 'lib/capybara/selector/regexp_disassembler.rb', line 188

def repeat_set(str)
  strs = Array(str * min_repeat)
  strs.push(nil) unless fixed_repeat?
  strs
end

#type (private)

[ GitHub ]

  
# File 'lib/capybara/selector/regexp_disassembler.rb', line 184

def type
  @exp.type
end