Class: Spectre::Operators::Optional
- Inherits:
-
Object
- Object
- Spectre::Operators::Optional
- Includes:
- Op
- Defined in:
- lib/spectre/base/operators.rb
Overview
Matches the given Node 0 or 1 times. Optional.new p is equal to -p
.
Instance Attribute Summary
Attributes included from Parser
Instance Method Summary collapse
Methods included from Op
Methods included from Parser
#backtrack, #create_match, from_POD, #pre_skip?, #to_p
Instance Method Details
#inspect ⇒ Object
314 315 316 |
# File 'lib/spectre/base/operators.rb', line 314 def inspect '(-' + @node.left.inspect + ')' end |
#scan(iter) ⇒ Object
304 305 306 307 308 309 310 311 312 |
# File 'lib/spectre/base/operators.rb', line 304 def scan iter ret = @node.left.parse iter if ret create_match iter, ret else backtrack iter create_match iter, iter.empty end end |