Class: Arugula::RangePart
Instance Method Summary collapse
-
#initialize(start, final) ⇒ RangePart
constructor
A new instance of RangePart.
- #match(str, index, _match_data) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Part
Constructor Details
#initialize(start, final) ⇒ RangePart
Returns a new instance of RangePart.
98 99 100 |
# File 'lib/arugula/parts.rb', line 98 def initialize(start, final) @range = start..final end |
Instance Method Details
#match(str, index, _match_data) ⇒ Object
106 107 108 109 |
# File 'lib/arugula/parts.rb', line 106 def match(str, index, _match_data) matches = @range.member?(str[index]) [matches, index + (matches ? 1 : 0)] end |
#to_s ⇒ Object
102 103 104 |
# File 'lib/arugula/parts.rb', line 102 def to_s "#{@range.begin}-#{@range.end}" end |