Class: RegexpExamples::Parser
- Inherits:
-
Object
- Object
- RegexpExamples::Parser
- Defined in:
- lib/regexp-examples/parser.rb
Instance Attribute Summary collapse
-
#regexp_string ⇒ Object
readonly
Returns the value of attribute regexp_string.
Instance Method Summary collapse
-
#initialize(regexp_string, options = {}) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(regexp_string, options = {}) ⇒ Parser
Returns a new instance of Parser.
4 5 6 7 8 9 10 11 12 |
# File 'lib/regexp-examples/parser.rb', line 4 def initialize(regexp_string, ={}) @regexp_string = regexp_string @num_groups = 0 @current_position = 0 RegexpExamples::ResultCountLimiters.configure!( [:max_repeater_variance], [:max_group_results] ) end |
Instance Attribute Details
#regexp_string ⇒ Object (readonly)
Returns the value of attribute regexp_string.
3 4 5 |
# File 'lib/regexp-examples/parser.rb', line 3 def regexp_string @regexp_string end |
Instance Method Details
#parse ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/regexp-examples/parser.rb', line 14 def parse repeaters = [] while @current_position < regexp_string.length group = parse_group(repeaters) break if group.is_a? MultiGroupEnd if group.is_a? OrGroup return [OneTimeRepeater.new(group)] end @current_position += 1 repeaters << parse_repeater(group) end repeaters end |