Class: Coradoc::Html::Spa::Configuration

Inherits:
ConverterBase::ConfigurationBase show all
Defined in:
lib/coradoc/html/spa.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.



19
20
21
22
23
24
25
26
27
# File 'lib/coradoc/html/spa.rb', line 19

def initialize(**options)
  @theme_toggle = options.fetch(:theme_toggle, true)
  @reading_progress = options.fetch(:reading_progress, true)
  @toc_sticky = options.fetch(:toc_sticky, true)
  @toc_levels = options[:toc_levels] || 2
  @lang = options[:lang] || 'en'
  @template_dirs = options[:template_dirs]
  @dist_dir = options[:dist_dir]
end

Instance Attribute Details

#dist_dirObject

Returns the value of attribute dist_dir.



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

def dist_dir
  @dist_dir
end

#langObject

Returns the value of attribute lang.



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

def lang
  @lang
end

#reading_progressObject

Returns the value of attribute reading_progress.



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

def reading_progress
  @reading_progress
end

#template_dirsObject

Returns the value of attribute template_dirs.



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

def template_dirs
  @template_dirs
end

#theme_toggleObject

Returns the value of attribute theme_toggle.



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

def theme_toggle
  @theme_toggle
end

#toc_levelsObject

Returns the value of attribute toc_levels.



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

def toc_levels
  @toc_levels
end

#toc_stickyObject

Returns the value of attribute toc_sticky.



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

def toc_sticky
  @toc_sticky
end

Instance Method Details

#to_hObject



29
30
31
32
33
34
35
# File 'lib/coradoc/html/spa.rb', line 29

def to_h
  {
    theme_toggle: @theme_toggle, reading_progress: @reading_progress,
    toc_sticky: @toc_sticky, toc_levels: @toc_levels,
    lang: @lang, template_dirs: @template_dirs, dist_dir: @dist_dir
  }
end

#validate!Object



37
38
39
40
41
42
# File 'lib/coradoc/html/spa.rb', line 37

def validate!
  return if @toc_levels.is_a?(Integer) && @toc_levels.between?(1, 5)

  raise ConverterBase::ValidationError,
        'TOC levels must be an integer between 1 and 5'
end