Class: Parslet::Atoms::Ignored
- Defined in:
- lib/parslet/atoms/ignored.rb
Overview
Ignores the result of a match.
Example:
str('foo') # will return 'foo',
str('foo').ignore # will return nil
Constant Summary
Constants included from Precedence
Precedence::ALTERNATE, Precedence::BASE, Precedence::LOOKAHEAD, Precedence::OUTER, Precedence::REPETITION, Precedence::SEQUENCE
Instance Attribute Summary collapse
-
#parslet ⇒ Object
readonly
Returns the value of attribute parslet.
Attributes inherited from Base
Instance Method Summary collapse
- #apply(source, context, consume_all) ⇒ Object
-
#initialize(parslet) ⇒ Ignored
constructor
A new instance of Ignored.
- #to_s_inner(prec) ⇒ Object
Methods inherited from Base
#accept, #cached?, #inspect, #parse, #parse_with_debug, precedence, #setup_and_apply, #to_s, #try
Methods included from CanFlatten
#flatten, #flatten_repetition, #flatten_sequence, #foldl, #merge_fold, #warn_about_duplicate_keys
Methods included from DSL
#>>, #absent?, #as, #capture, #ignore, #maybe, #present?, #repeat, #|
Constructor Details
#initialize(parslet) ⇒ Ignored
Returns a new instance of Ignored.
10 11 12 13 14 |
# File 'lib/parslet/atoms/ignored.rb', line 10 def initialize(parslet) super() @parslet = parslet end |
Instance Attribute Details
#parslet ⇒ Object (readonly)
Returns the value of attribute parslet.
9 10 11 |
# File 'lib/parslet/atoms/ignored.rb', line 9 def parslet @parslet end |
Instance Method Details
#apply(source, context, consume_all) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/parslet/atoms/ignored.rb', line 16 def apply(source, context, consume_all) success, _ = result = parslet.apply(source, context, consume_all) return result unless success succ(nil) end |
#to_s_inner(prec) ⇒ Object
23 24 25 |
# File 'lib/parslet/atoms/ignored.rb', line 23 def to_s_inner(prec) "ignored(#{parslet.to_s(prec)})" end |