Class: Markbridge::AST::Image

Inherits:
Element show all
Defined in:
lib/markbridge/ast/image.rb

Overview

Represents an image element.

Examples:

Basic image

image = AST::Image.new(src: "https://example.com/img.png")

Image with dimensions

image = AST::Image.new(src: "https://example.com/img.png", width: 100, height: 100)

Instance Attribute Summary collapse

Attributes inherited from Element

#children

Instance Method Summary collapse

Methods inherited from Element

#<<

Constructor Details

#initialize(src: nil, width: nil, height: nil) ⇒ Image

Create a new Image element.

Parameters:

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

    the image source URL

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

    the image width

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

    the image height



27
28
29
30
31
32
# File 'lib/markbridge/ast/image.rb', line 27

def initialize(src: nil, width: nil, height: nil)
  super()
  @src = src
  @width = width
  @height = height
end

Instance Attribute Details

#heightInteger? (readonly)

Returns the image height.

Returns:

  • (Integer, nil)

    the image height



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

def height
  @height
end

#srcString? (readonly)

Returns the image source URL.

Returns:

  • (String, nil)

    the image source URL



14
15
16
# File 'lib/markbridge/ast/image.rb', line 14

def src
  @src
end

#widthInteger? (readonly)

Returns the image width.

Returns:

  • (Integer, nil)

    the image width



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

def width
  @width
end