Class: Arugula::QuantifierPart

Inherits:
Part
  • Object
show all
Includes:
MatchNTimes
Defined in:
lib/arugula/parts.rb

Instance Attribute Summary

Attributes included from Wrapping

#wrapped

Instance Method Summary collapse

Methods included from MatchNTimes

#match

Methods inherited from Part

all, inherited, type

Constructor Details

#initialize(before, after, *args) ⇒ QuantifierPart

Returns a new instance of QuantifierPart.



268
269
270
# File 'lib/arugula/parts.rb', line 268

def initialize(before, after, *args)
  super(*args, times: before..after)
end

Instance Method Details

#to_sObject



272
273
274
275
276
277
278
279
280
281
282
# File 'lib/arugula/parts.rb', line 272

def to_s
  before = @times.begin
  after = @times.end
  quantifier_part = '{'.dup
  quantifier_part << before.to_s unless before == 0
  quantifier_part << ',' unless before == after
  quantifier_part << after.to_s unless before == after ||
                                       after == Float::INFINITY
  quantifier_part << '}'
  "#{wrapped}#{quantifier_part}"
end