Class: Markbridge::Parsers::HTML::Handlers::SelfClosingHandler

Inherits:
BaseHandler
  • Object
show all
Defined in:
lib/markbridge/parsers/html/handlers/self_closing_handler.rb

Overview

Handler for self-closing leaf tags (br, hr, etc.). Creates an instance of element_class, appends it to parent, and returns nil so the parser does not try to recurse into children.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element_class) ⇒ SelfClosingHandler

Returns a new instance of SelfClosingHandler.



12
13
14
# File 'lib/markbridge/parsers/html/handlers/self_closing_handler.rb', line 12

def initialize(element_class)
  @element_class = element_class
end

Instance Attribute Details

#element_classObject (readonly)

Returns the value of attribute element_class.



21
22
23
# File 'lib/markbridge/parsers/html/handlers/self_closing_handler.rb', line 21

def element_class
  @element_class
end

Instance Method Details

#process(element:, parent:) ⇒ Object



16
17
18
19
# File 'lib/markbridge/parsers/html/handlers/self_closing_handler.rb', line 16

def process(element:, parent:)
  parent << @element_class.new
  nil
end