Class: AsciidoctorVaped::Parser::Blocks::BaseNode

Inherits:
Object
  • Object
show all
Defined in:
lib/asciidoctor_vaped/parser/blocks/common/base_node.rb

Instance Method Summary collapse

Constructor Details

#initialize(successor = nil) ⇒ BaseNode

Returns a new instance of BaseNode.



7
8
9
# File 'lib/asciidoctor_vaped/parser/blocks/common/base_node.rb', line 7

def initialize(successor = nil)
  @successor = successor
end

Instance Method Details

#handle(context) ⇒ Object



11
12
13
14
15
# File 'lib/asciidoctor_vaped/parser/blocks/common/base_node.rb', line 11

def handle(context)
  return parse(context) if match?(context)

  @successor&.handle(context)
end

#match?(context) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/asciidoctor_vaped/parser/blocks/common/base_node.rb', line 17

def match?(context)
  context.reader.peek&.match?(self.class::PATTERN)
end