Class: RegexpExamples::RangeRepeater
- Inherits:
-
BaseRepeater
- Object
- BaseRepeater
- RegexpExamples::RangeRepeater
- Defined in:
- lib/regexp-examples/repeaters.rb
Overview
When a range is used, e.g. ‘/a1/`, `/a1,/`, `/a1,3/`, `/a,3/`
Instance Attribute Summary
Attributes inherited from BaseRepeater
#group, #max_repeats, #min_repeats
Instance Method Summary collapse
-
#initialize(group, min, has_comma, max) ⇒ RangeRepeater
constructor
A new instance of RangeRepeater.
Methods inherited from BaseRepeater
Constructor Details
#initialize(group, min, has_comma, max) ⇒ RangeRepeater
Returns a new instance of RangeRepeater.
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/regexp-examples/repeaters.rb', line 80 def initialize(group, min, has_comma, max) super(group) @min_repeats = min || 0 @max_repeats = if has_comma # e.g. a{1,}, a{,3} or a{1,3} [ max, @min_repeats + RegexpExamples::Config.max_repeater_variance ].compact.min else # e.g. a{1} @min_repeats end end |