class RegexpExamples::RangeRepeater

When a range is used, e.g. ‘/a{1}/`, `/a{1,}/`, `/a{1,3}/`, `/a{,3}/`

Public Class Methods

new(group, min, has_comma, max) click to toggle source
Calls superclass method RegexpExamples::BaseRepeater::new
# 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