Class: Coradoc::CoreModel::Image

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/core_model/image.rb

Overview

Represents an image in a document

Images can be block-level (standalone) or inline. They support various attributes like alt text, dimensions, and linking.

Examples:

Creating a block image

image = CoreModel::Image.new(
  src: "images/diagram.png",
  alt: "System Architecture",
  caption: "Figure 1: System Overview",
  width: "800px"
)

Creating an inline image

icon = CoreModel::Image.new(
  src: "icons/warning.png",
  alt: "Warning",
  inline: true
)

Instance Attribute Summary collapse

Attributes inherited from Base

#element_attributes, #id, #metadata_entries, #title

Method Summary

Methods inherited from Base

#accept, #attr, #metadata, #semantically_equivalent?, #set_attr, #set_metadata

Instance Attribute Details

#altString?

Returns alternative text for accessibility.

Returns:

  • (String, nil)

    alternative text for accessibility



31
# File 'lib/coradoc/core_model/image.rb', line 31

attribute :alt, :string

#captionString?

Note:

Populated by HTML converter only

Returns caption text for the image.

Returns:

  • (String, nil)

    caption text for the image



36
# File 'lib/coradoc/core_model/image.rb', line 36

attribute :caption, :string

#floatString?

Note:

Not yet wired by any transformer; reserved for future use

Returns float position (‘left’, ‘right’).

Returns:

  • (String, nil)

    float position (‘left’, ‘right’)



58
# File 'lib/coradoc/core_model/image.rb', line 58

attribute :float, :string

#heightString?

Returns image height (e.g., ‘300px’, ‘auto’).

Returns:

  • (String, nil)

    image height (e.g., ‘300px’, ‘auto’)



44
# File 'lib/coradoc/core_model/image.rb', line 44

attribute :height, :string

#inlineBoolean

Returns whether this is an inline image.

Returns:

  • (Boolean)

    whether this is an inline image



53
# File 'lib/coradoc/core_model/image.rb', line 53

attribute :inline, :boolean, default: -> { false }
Note:

Not yet wired by any transformer; reserved for future use

Returns URL to link to when image is clicked.

Returns:

  • (String, nil)

    URL to link to when image is clicked



49
# File 'lib/coradoc/core_model/image.rb', line 49

attribute :link, :string

#srcString?

Returns source URL or path to the image.

Returns:

  • (String, nil)

    source URL or path to the image



27
# File 'lib/coradoc/core_model/image.rb', line 27

attribute :src, :string

#widthString?

Returns image width (e.g., ‘100%’, ‘500px’).

Returns:

  • (String, nil)

    image width (e.g., ‘100%’, ‘500px’)



40
# File 'lib/coradoc/core_model/image.rb', line 40

attribute :width, :string