Class: Coradoc::Html::Static::Configuration

Inherits:
ConverterBase::ConfigurationBase show all
Defined in:
lib/coradoc/html/static.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ConverterBase::ConfigurationBase

defaults, #merge

Constructor Details

#initialize(**options) ⇒ Configuration

Returns a new instance of Configuration.



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/coradoc/html/static.rb', line 20

def initialize(**options)
  @include_toc = options.fetch(:include_toc, false)
  @toc_levels = options[:toc_levels] || 2
  @section_numbering = options.fetch(:section_numbering, false)
  @section_numbering_levels = options[:section_numbering_levels] || 3
  @lang = options[:lang] || 'en'
  @meta_tags = options[:meta_tags] || {}
  @custom_css = options[:custom_css]
  @embedded = options.fetch(:embedded, false)
  @template_dirs = options[:template_dirs]
end

Instance Attribute Details

#custom_cssObject

Returns the value of attribute custom_css.



15
16
17
# File 'lib/coradoc/html/static.rb', line 15

def custom_css
  @custom_css
end

#embeddedObject

Returns the value of attribute embedded.



15
16
17
# File 'lib/coradoc/html/static.rb', line 15

def embedded
  @embedded
end

#include_tocObject

Returns the value of attribute include_toc.



15
16
17
# File 'lib/coradoc/html/static.rb', line 15

def include_toc
  @include_toc
end

#langObject

Returns the value of attribute lang.



15
16
17
# File 'lib/coradoc/html/static.rb', line 15

def lang
  @lang
end

#meta_tagsObject

Returns the value of attribute meta_tags.



15
16
17
# File 'lib/coradoc/html/static.rb', line 15

def meta_tags
  @meta_tags
end

#section_numberingObject

Returns the value of attribute section_numbering.



15
16
17
# File 'lib/coradoc/html/static.rb', line 15

def section_numbering
  @section_numbering
end

#section_numbering_levelsObject

Returns the value of attribute section_numbering_levels.



15
16
17
# File 'lib/coradoc/html/static.rb', line 15

def section_numbering_levels
  @section_numbering_levels
end

#template_dirsObject

Returns the value of attribute template_dirs.



15
16
17
# File 'lib/coradoc/html/static.rb', line 15

def template_dirs
  @template_dirs
end

#toc_levelsObject

Returns the value of attribute toc_levels.



15
16
17
# File 'lib/coradoc/html/static.rb', line 15

def toc_levels
  @toc_levels
end

Instance Method Details

#to_hObject



32
33
34
35
36
37
38
39
40
# File 'lib/coradoc/html/static.rb', line 32

def to_h
  {
    include_toc: @include_toc, toc_levels: @toc_levels,
    section_numbering: @section_numbering,
    section_numbering_levels: @section_numbering_levels,
    lang: @lang, meta_tags: @meta_tags, custom_css: @custom_css,
    embedded: @embedded, template_dirs: @template_dirs
  }
end

#validate!Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/coradoc/html/static.rb', line 42

def validate!
  unless @toc_levels.is_a?(Integer) && @toc_levels.between?(1, 5)
    raise ConverterBase::ValidationError,
          'TOC levels must be an integer between 1 and 5'
  end

  unless @section_numbering_levels.is_a?(Integer) &&
         @section_numbering_levels.between?(1, 6)
    raise ConverterBase::ValidationError,
          'Section numbering levels must be an integer between 1 and 6'
  end
end