Class: Coradoc::Html::Drop::DocumentDrop

Inherits:
Base
  • Object
show all
Includes:
SectionNumberable
Defined in:
lib/coradoc/html/drop/document_drop.rb

Instance Attribute Summary

Attributes included from SectionNumberable

#section_number

Attributes inherited from Base

#model

Instance Method Summary collapse

Methods inherited from Base

#id, #initialize, #to_liquid

Constructor Details

This class inherits a constructor from Coradoc::Html::Drop::Base

Instance Method Details

#childrenObject



26
27
28
# File 'lib/coradoc/html/drop/document_drop.rb', line 26

def children
  children_to_liquid(@model.children)
end

#heading_levelObject



40
41
42
43
44
45
46
# File 'lib/coradoc/html/drop/document_drop.rb', line 40

def heading_level
  if @model.is_a?(CoreModel::SectionElement)
    [@model.heading_level + 1, 6].min
  else
    1
  end
end

#structural_typeObject



30
31
32
33
34
35
36
37
38
# File 'lib/coradoc/html/drop/document_drop.rb', line 30

def structural_type
  case @model
  when CoreModel::DocumentElement then 'document'
  when CoreModel::SectionElement then 'section'
  when CoreModel::HeaderElement then 'header'
  when CoreModel::PreambleElement then 'preamble'
  else 'structural'
  end
end

#template_typeObject



9
10
11
12
13
# File 'lib/coradoc/html/drop/document_drop.rb', line 9

def template_type
  return 'document' if @model.is_a?(CoreModel::DocumentElement)

  'section'
end

#titleObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/coradoc/html/drop/document_drop.rb', line 15

def title
  text = TitleText.resolve(@model.title)
  return nil unless text && !text.empty?

  if @section_number
    Escape.escape_html("#{@section_number}. #{text}")
  else
    Escape.escape_html(text)
  end
end