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.
139 140 141 142 |
# File 'lib/arugula/parts.rb', line 139 def initialize(name) @name = name super() end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
137 138 139 |
# File 'lib/arugula/parts.rb', line 137 def name @name end |
Instance Method Details
#match(str, index, match_data) ⇒ Object
148 149 150 151 152 |
# File 'lib/arugula/parts.rb', line 148 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
144 145 146 |
# File 'lib/arugula/parts.rb', line 144 def to_s "(#{parts.join})" end |