Class: Coradoc::Markdown::Parser::ParsletExtras::DynamicOutput
- Inherits:
-
Parslet::Atoms::Base
- Object
- Parslet::Atoms::Base
- Coradoc::Markdown::Parser::ParsletExtras::DynamicOutput
- Defined in:
- lib/coradoc/markdown/parser/parslet_extras.rb
Instance Attribute Summary collapse
-
#callable ⇒ Object
readonly
Returns the value of attribute callable.
-
#parslet ⇒ Object
readonly
Returns the value of attribute parslet.
Instance Method Summary collapse
- #apply(source, context, consume_all) ⇒ Object
-
#initialize(parslet, callable) ⇒ DynamicOutput
constructor
A new instance of DynamicOutput.
- #to_s_inner(prec) ⇒ Object
Constructor Details
#initialize(parslet, callable) ⇒ DynamicOutput
Returns a new instance of DynamicOutput.
90 91 92 93 94 95 |
# File 'lib/coradoc/markdown/parser/parslet_extras.rb', line 90 def initialize(parslet, callable) super() @parslet = parslet @callable = callable end |
Instance Attribute Details
#callable ⇒ Object (readonly)
Returns the value of attribute callable.
88 89 90 |
# File 'lib/coradoc/markdown/parser/parslet_extras.rb', line 88 def callable @callable end |
#parslet ⇒ Object (readonly)
Returns the value of attribute parslet.
88 89 90 |
# File 'lib/coradoc/markdown/parser/parslet_extras.rb', line 88 def parslet @parslet end |
Instance Method Details
#apply(source, context, consume_all) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/coradoc/markdown/parser/parslet_extras.rb', line 97 def apply(source, context, consume_all) success, value = result = parslet.apply(source, context, consume_all) return result unless success succ(@callable.call(flatten(value))) end |
#to_s_inner(prec) ⇒ Object
105 106 107 |
# File 'lib/coradoc/markdown/parser/parslet_extras.rb', line 105 def to_s_inner(prec) "#{callable}:#{parslet.to_s(prec)}" end |