class Bookwatch::Config::DitaConfigGenerator

Attributes

section_hash[R]

Public Class Methods

new(section_hash) click to toggle source
# File lib/bookwatch/config/dita_config_generator.rb, line 7
def initialize(section_hash)
  @section_hash = section_hash
end

Public Instance Methods

ditamap_location() click to toggle source
# File lib/bookwatch/config/dita_config_generator.rb, line 17
def ditamap_location
  section_hash['ditamap_location'] if section_hash['ditamap_location'] && !section_hash['ditamap_location'].empty?
end
pdf_output_filename() click to toggle source
# File lib/bookwatch/config/dita_config_generator.rb, line 21
def pdf_output_filename
  if present?(section_hash['output_filename'])
    filename = section_hash['output_filename']
  elsif ditamap_location
    filename =  ditamap_location.gsub(/\.ditamap/, '')
  else
    return
  end

  filename + '.pdf'
end
preprocessor_config() click to toggle source
# File lib/bookwatch/config/dita_config_generator.rb, line 33
def preprocessor_config
  {
    'preprocessor_config' => {
      'ditamap_location' => ditamap_location,
      'ditaval_location' => section_hash['ditaval_location']
    }
  }
end
subnav_template() click to toggle source
to_hash() click to toggle source
# File lib/bookwatch/config/dita_config_generator.rb, line 42
def to_hash
  section_hash.tap do |hash|
    hash.merge!(preprocessor_config)
        .merge!('subnav_template' => subnav_template, 'output_filename' => pdf_output_filename)

    hash.delete('ditaval_location')
    hash.delete('ditamap_location')
  end
end

Private Instance Methods

present?(value) click to toggle source
# File lib/bookwatch/config/dita_config_generator.rb, line 56
def present?(value)
  value && !value.empty?
end