Class: Smartdown::Parser::NodeInterpreter

Inherits:
Object
  • Object
show all
Defined in:
lib/smartdown/parser/node_interpreter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, source, options = {}) ⇒ NodeInterpreter

Returns a new instance of NodeInterpreter.



12
13
14
15
16
17
# File 'lib/smartdown/parser/node_interpreter.rb', line 12

def initialize(name, source, options = {})
  @name = name
  @source = source
  @parser = options.fetch(:parser, Smartdown::Parser::NodeParser.new)
  @transform = options.fetch(:transform, Smartdown::Parser::NodeTransform.new)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/smartdown/parser/node_interpreter.rb', line 10

def name
  @name
end

#sourceObject (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

#interpretObject



19
20
21
22
23
# File 'lib/smartdown/parser/node_interpreter.rb', line 19

def interpret
  transform.apply(parser.parse(source),
    node_name: name
  )
end