Class: Arugula::RangePart
Instance Method Summary collapse
-
#initialize(start, final) ⇒ RangePart
constructor
A new instance of RangePart.
- #match(str, index) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Part
Constructor Details
#initialize(start, final) ⇒ RangePart
Returns a new instance of RangePart.
83 84 85 |
# File 'lib/arugula/parts.rb', line 83 def initialize(start, final) @range = start..final end |
Instance Method Details
#match(str, index) ⇒ Object
91 92 93 94 |
# File 'lib/arugula/parts.rb', line 91 def match(str, index) matches = @range.member?(str[index]) [matches, index + (matches ? 1 : 0)] end |
#to_s ⇒ Object
87 88 89 |
# File 'lib/arugula/parts.rb', line 87 def to_s "#{@range.begin}-#{@range.end}" end |