Class: Rrrex::NumberMatch

Inherits:
Match
  • Object
show all
Includes:
SingleAtomMatch
Defined in:
lib/rrrex/number_match.rb

Instance Attribute Summary

Attributes included from SingleAtomMatch

#atom

Instance Method Summary collapse

Methods included from SingleAtomMatch

#group_names

Methods inherited from Match

#+, convert, #group_names, #match, #not, #or, #wrap

Constructor Details

#initialize(a, min, max) ⇒ NumberMatch

Returns a new instance of NumberMatch.



6
7
8
9
10
# File 'lib/rrrex/number_match.rb', line 6

def initialize( a, min, max )
  super a
  @min = min
  @max = max
end

Instance Method Details

#to_regexp_stringObject



12
13
14
15
# File 'lib/rrrex/number_match.rb', line 12

def to_regexp_string
  # Subtle: when nil, we want min to convert to 0, but max to convert to ""
  wrap atom.to_regexp_string + "{#{@min.to_i},#{@max}}"
end