Class: Arugula::RangePart

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

Instance Method Summary collapse

Methods inherited from Part

all, inherited, type

Constructor Details

#initialize(start, final) ⇒ RangePart

Returns a new instance of RangePart.



91
92
93
# File 'lib/arugula/parts.rb', line 91

def initialize(start, final)
  @range = start..final
end

Instance Method Details

#match(str, index, _match_data) ⇒ Object



99
100
101
102
# File 'lib/arugula/parts.rb', line 99

def match(str, index, _match_data)
  matches = @range.member?(str[index])
  [matches, index + (matches ? 1 : 0)]
end

#to_sObject



95
96
97
# File 'lib/arugula/parts.rb', line 95

def to_s
  "#{@range.begin}-#{@range.end}"
end