Class: Arrolio::Flowables::HeadingFlowable

Inherits:
TextFlowable show all
Defined in:
lib/arrolio/flowables/heading_flowable.rb

Overview

A section heading: optional number + title text. Lives separate from TextFlowable so the adapter and Engine can recognise headings by type (for outline / TOC building).

Instance Attribute Summary collapse

Attributes inherited from TextFlowable

#measurer, #runs

Attributes inherited from Arrolio::Flowable

#style

Instance Method Summary collapse

Methods inherited from TextFlowable

#do_split, #emit, #height, #splittable?

Methods inherited from Arrolio::Flowable

#do_split, #emit, #height, #keep_together?, #keep_with_next?, #page_break_after?, #page_break_before?, #space_after, #space_before, #split, #splittable?

Constructor Details

#initialize(title, level: 1, number: nil, id: nil, style: Style::Definition.new, measurer: nil) ⇒ HeadingFlowable

Returns a new instance of HeadingFlowable.



11
12
13
14
15
16
17
18
19
20
# File 'lib/arrolio/flowables/heading_flowable.rb', line 11

def initialize(title, level: 1, number: nil, id: nil,
               style: Style::Definition.new, measurer: nil)
  full_text = number ? "#{number} #{title}" : title.to_s
  super([InlineRun.new(full_text, style: style)],
        style: style, measurer: measurer)
  @title = title
  @level = level.to_i
  @number = number
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/arrolio/flowables/heading_flowable.rb', line 9

def id
  @id
end

#levelObject (readonly)

Returns the value of attribute level.



9
10
11
# File 'lib/arrolio/flowables/heading_flowable.rb', line 9

def level
  @level
end

#numberObject (readonly)

Returns the value of attribute number.



9
10
11
# File 'lib/arrolio/flowables/heading_flowable.rb', line 9

def number
  @number
end

#titleObject (readonly)

Returns the value of attribute title.



9
10
11
# File 'lib/arrolio/flowables/heading_flowable.rb', line 9

def title
  @title
end