Class: Arrolio::Content::FigureGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/arrolio/content/figure_group.rb

Overview

A figure group: optional Image plus optional caption Paragraph. Replaces the previous flat [Image, Paragraph] emission from convert_figure. The flow builder renders the group as a keep-together unit so the caption never lands on a different page from the image.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image: nil, caption: nil, id: nil, style_id: :figure) ⇒ FigureGroup

Returns a new instance of FigureGroup.



13
14
15
16
17
18
19
# File 'lib/arrolio/content/figure_group.rb', line 13

def initialize(image: nil, caption: nil, id: nil, style_id: :figure)
  @image = image
  @caption = caption
  @id = id&.to_s
  @style_id = style_id.to_sym
  freeze
end

Instance Attribute Details

#captionObject (readonly)

Returns the value of attribute caption.



11
12
13
# File 'lib/arrolio/content/figure_group.rb', line 11

def caption
  @caption
end

#idObject (readonly)

Returns the value of attribute id.



11
12
13
# File 'lib/arrolio/content/figure_group.rb', line 11

def id
  @id
end

#imageObject (readonly)

Returns the value of attribute image.



11
12
13
# File 'lib/arrolio/content/figure_group.rb', line 11

def image
  @image
end

#style_idObject (readonly)

Returns the value of attribute style_id.



11
12
13
# File 'lib/arrolio/content/figure_group.rb', line 11

def style_id
  @style_id
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



25
26
27
28
29
30
31
# File 'lib/arrolio/content/figure_group.rb', line 25

def ==(other)
  other.is_a?(self.class) &&
    image == other.image &&
    caption == other.caption &&
    id == other.id &&
    style_id == other.style_id
end

#empty?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/arrolio/content/figure_group.rb', line 21

def empty?
  @image.nil? && (@caption.nil? || (@caption.is_a?(Paragraph) && @caption.empty?))
end

#hashObject



34
35
36
# File 'lib/arrolio/content/figure_group.rb', line 34

def hash
  [self.class, image, caption, id, style_id].hash
end