Class: Markbridge::AST::Attachment

Inherits:
Node
  • Object
show all
Defined in:
lib/markbridge/ast/attachment.rb

Overview

Represents an attachment reference (image/file).

Examples:

Attachment by absolute ID

attachment = AST::Attachment.new(id: "1234")

Attachment by post-relative index with filename

attachment = AST::Attachment.new(index: "0", filename: "image.jpg")

Attachment with alt text

attachment = AST::Attachment.new(id: "5678", alt: "diagram")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, index: nil, filename: nil, alt: nil) ⇒ Attachment

Create a new Attachment node.

Parameters:

  • id (String, Integer, nil) (defaults to: nil)

    absolute attachment identifier

  • index (Integer, nil) (defaults to: nil)

    post-relative index

  • filename (String, nil) (defaults to: nil)

    optional filename/caption

  • alt (String, nil) (defaults to: nil)

    optional alt text



34
35
36
37
38
39
# File 'lib/markbridge/ast/attachment.rb', line 34

def initialize(id: nil, index: nil, filename: nil, alt: nil)
  @id = id
  @index = index
  @filename = filename
  @alt = alt
end

Instance Attribute Details

#altString? (readonly)

Returns optional alt text for the attachment.

Returns:

  • (String, nil)

    optional alt text for the attachment



26
27
28
# File 'lib/markbridge/ast/attachment.rb', line 26

def alt
  @alt
end

#filenameString? (readonly)

Returns optional filename.

Returns:

  • (String, nil)

    optional filename



23
24
25
# File 'lib/markbridge/ast/attachment.rb', line 23

def filename
  @filename
end

#idString, ... (readonly)

Returns absolute attachment identifier.

Returns:

  • (String, Integer, nil)

    absolute attachment identifier



17
18
19
# File 'lib/markbridge/ast/attachment.rb', line 17

def id
  @id
end

#indexInteger? (readonly)

Returns post-relative index.

Returns:

  • (Integer, nil)

    post-relative index



20
21
22
# File 'lib/markbridge/ast/attachment.rb', line 20

def index
  @index
end