Class: Pdfrb::Layout::InlineBox

Inherits:
Box
  • Object
show all
Defined in:
lib/pdfrb/layout/inline_box.rb

Overview

A box that sits inline within a text line (e.g., a styled span or an inline icon). Width + height are fixed; Line arranges it alongside TextFragments.

Instance Attribute Summary collapse

Attributes inherited from Box

#height, #style, #width

Instance Method Summary collapse

Methods inherited from Box

#draw, #empty?, #fit?

Constructor Details

#initialize(width:, height:, &block) ⇒ InlineBox

Returns a new instance of InlineBox.



11
12
13
14
# File 'lib/pdfrb/layout/inline_box.rb', line 11

def initialize(width:, height:, &block)
  super(width: width, height: height)
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



9
10
11
# File 'lib/pdfrb/layout/inline_box.rb', line 9

def block
  @block
end

Instance Method Details

#draw_content(canvas, x, y) ⇒ Object



20
21
22
# File 'lib/pdfrb/layout/inline_box.rb', line 20

def draw_content(canvas, x, y)
  @block&.call(canvas, x, y)
end

#supports_position_flow?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/pdfrb/layout/inline_box.rb', line 16

def supports_position_flow?
  true
end