Class: Arugula
- Inherits:
-
Object
- Object
- Arugula
- Defined in:
- lib/arugula.rb,
lib/arugula/parts.rb,
lib/arugula/parser.rb,
lib/arugula/version.rb,
lib/arugula/match_data.rb
Defined Under Namespace
Modules: MatchAll, MatchAny, Wrapping Classes: AndPart, CapturePart, CharacterClassPart, DotPart, EOLPart, LiteralPart, MatchData, MetacharacterPart, OrPart, Parser, Part, PlusPart, RangePart, SOLPart, StarPart
Constant Summary collapse
- VERSION =
'0.3.0'.freeze
Instance Attribute Summary collapse
-
#captures ⇒ Object
readonly
Returns the value of attribute captures.
Instance Method Summary collapse
-
#initialize(pattern) ⇒ Arugula
constructor
A new instance of Arugula.
- #match(str, index = 0) ⇒ Object
- #match?(str, index = 0) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#captures ⇒ Object (readonly)
Returns the value of attribute captures.
5 6 7 |
# File 'lib/arugula.rb', line 5 def captures @captures end |
Instance Method Details
#match(str, index = 0) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/arugula.rb', line 19 def match(str, index = 0) match_data = MatchData.new(self, str) loop do match, end_index = @root.match(str, index, match_data) if match match_data.start_index = index match_data.end_index = end_index return match_data.freeze end index += 1 return if index > str.size end end |
#match?(str, index = 0) ⇒ Boolean
14 15 16 17 |
# File 'lib/arugula.rb', line 14 def match?(str, index = 0) match_data = match(str, index) match_data && match_data.start_index end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/arugula.rb', line 33 def to_s "/#{@root}/" end |