Class: Spectre::StringParsing::CharParser
- Inherits:
-
Object
- Object
- Spectre::StringParsing::CharParser
- Includes:
- Parser
- Defined in:
- lib/spectre/string/primitives.rb
Overview
Matches one single character. Shortcut: char
.
Instance Attribute Summary
Attributes included from Parser
Instance Method Summary collapse
-
#initialize(char) ⇒ CharParser
constructor
A new instance of CharParser.
- #inspect ⇒ Object
- #negation ⇒ Object
- #scan(iter) ⇒ Object
Methods included from Parser
#backtrack, #create_match, from_POD, #pre_skip?, #to_p
Constructor Details
#initialize(char) ⇒ CharParser
Returns a new instance of CharParser.
54 55 56 57 |
# File 'lib/spectre/string/primitives.rb', line 54 def initialize char super() @char = char end |
Instance Method Details
#inspect ⇒ Object
69 70 71 |
# File 'lib/spectre/string/primitives.rb', line 69 def inspect "[char:'#{@char}']" end |
#negation ⇒ Object
59 |
# File 'lib/spectre/string/primitives.rb', line 59 def negation; Negations::NegatedSingleTokenParser.new; end |
#scan(iter) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/spectre/string/primitives.rb', line 61 def scan iter if iter.valid? and +iter == @char create_match iter, @char else nil end end |