Class: Arugula::CapturePart
- Includes:
- MatchAll
- Defined in:
- lib/arugula/parts.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes included from MatchAll
Instance Method Summary collapse
-
#initialize(name) ⇒ CapturePart
constructor
A new instance of CapturePart.
- #match(str, index, match_data) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Part
Constructor Details
#initialize(name) ⇒ CapturePart
Returns a new instance of CapturePart.
150 151 152 153 |
# File 'lib/arugula/parts.rb', line 150 def initialize(name) @name = name super() end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
148 149 150 |
# File 'lib/arugula/parts.rb', line 148 def name @name end |
Instance Method Details
#match(str, index, match_data) ⇒ Object
159 160 161 162 163 |
# File 'lib/arugula/parts.rb', line 159 def match(str, index, match_data) matches, end_index = super match_data.add_capture(@name, index, end_index) if matches [matches, end_index] end |
#to_s ⇒ Object
155 156 157 |
# File 'lib/arugula/parts.rb', line 155 def to_s "(#{parts.join})" end |