Class: Regex::Anchor
- Inherits:
-
AtomicExpression
- Object
- Expression
- AtomicExpression
- Regex::Anchor
- Defined in:
- lib/regex/anchor.rb
Overview
An anchor is a zero-width assertion based on the current position.
Constant Summary collapse
- AnchorToSymbol =
A Hash for converting a lexeme to a symbolic value
{ # Lexeme => Symbol value '^' => :soLine, # Start of line '$' => :eoLine, # End of line '\A' => :soSubject, '\b' => :wordBoundary, '\B' => :nonAtWordBoundary, '\G' => :firstMatch, '\z' => :eoSubject, '\Z' => :eoSubjectOrBeforeNLAtEnd }.freeze
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
A symbolic value that identifies the type of assertion to perform.
Attributes inherited from Expression
Instance Method Summary collapse
-
#initialize(aKind) ⇒ Anchor
constructor
Constructor.
-
#to_str ⇒ Object
Conversion method re-definition.
Methods inherited from AtomicExpression
Methods inherited from Expression
Constructor Details
#initialize(aKind) ⇒ Anchor
Constructor
26 27 28 |
# File 'lib/regex/anchor.rb', line 26 def initialize(aKind) @kind = valid_kind(aKind) end |
Instance Attribute Details
#kind ⇒ Object (readonly)
A symbolic value that identifies the type of assertion to perform
22 23 24 |
# File 'lib/regex/anchor.rb', line 22 def kind @kind end |
Instance Method Details
#to_str ⇒ Object
Conversion method re-definition. Purpose: Return the String representation of the expression.
32 33 34 |
# File 'lib/regex/anchor.rb', line 32 def to_str AnchorToSymbol.rassoc(kind).first end |