Class: Smartdown::Parser::NodeInterpreter
- Inherits:
-
Object
- Object
- Smartdown::Parser::NodeInterpreter
- Defined in:
- lib/smartdown/parser/node_interpreter.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(name, source, options = {}) ⇒ NodeInterpreter
constructor
A new instance of NodeInterpreter.
- #interpret ⇒ Object
Constructor Details
#initialize(name, source, options = {}) ⇒ NodeInterpreter
Returns a new instance of NodeInterpreter.
12 13 14 15 16 17 18 19 |
# File 'lib/smartdown/parser/node_interpreter.rb', line 12 def initialize(name, source, = {}) @name = name @source = source data_module = .fetch(:data_module, {}) @parser = .fetch(:parser, Smartdown::Parser::NodeParser.new) @transform = .fetch(:transform, Smartdown::Parser::NodeTransform.new(data_module)) @reporter = .fetch(:reporter, Parslet::ErrorReporter::Deepest.new) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/smartdown/parser/node_interpreter.rb', line 10 def name @name end |
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
10 11 12 |
# File 'lib/smartdown/parser/node_interpreter.rb', line 10 def reporter @reporter end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
10 11 12 |
# File 'lib/smartdown/parser/node_interpreter.rb', line 10 def source @source end |
Instance Method Details
#interpret ⇒ Object
21 22 23 24 25 |
# File 'lib/smartdown/parser/node_interpreter.rb', line 21 def interpret transform.apply(parser.parse(source, reporter: reporter), node_name: name ) end |