Class: Markbridge::Parsers::TextFormatter::Handlers::AttachmentHandler

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

Overview

Handler for ATTACHMENT and ATTACH elements in s9e/TextFormatter XML

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAttachmentHandler

Returns a new instance of AttachmentHandler.



9
10
11
# File 'lib/markbridge/parsers/text_formatter/handlers/attachment_handler.rb', line 9

def initialize
  @element_class = AST::Attachment
end

Instance Attribute Details

#element_classObject (readonly)

Returns the value of attribute element_class.



28
29
30
# File 'lib/markbridge/parsers/text_formatter/handlers/attachment_handler.rb', line 28

def element_class
  @element_class
end

Instance Method Details

#process(element:, parent:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/markbridge/parsers/text_formatter/handlers/attachment_handler.rb', line 13

def process(element:, parent:)
  attrs = extract_attributes(element)
  node =
    AST::Attachment.new(
      id: attrs[:id],
      index: attrs[:index],
      filename: attrs[:filename],
      alt: attrs[:alt],
    )
  parent << node

  # Return node to signal: process children into this node
  node
end