Class: Dictum::HtmlWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/dictum/html_writer.rb

Overview

rubocop:disable ClassLength

Constant Summary collapse

ERROR_CODE_URL =
'error_codes'.freeze
ERROR_CODE_TEXT =
'Error codes'.freeze
RESOURCES_TEXT =
'Resources'.freeze
BACK_TEXT =
'Back'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output_dir, temp_path, config) ⇒ HtmlWriter

Returns a new instance of HtmlWriter.



15
16
17
18
19
20
21
# File 'lib/dictum/html_writer.rb', line 15

def initialize(output_dir, temp_path, config)
  @output_dir = output_dir
  @temp_path = temp_path
  @temp_json = JSON.parse(File.read(temp_path))
  @config = config
  @header_title = config[:header_title]
end

Instance Attribute Details

#header_titleObject (readonly)

Returns the value of attribute header_title.



13
14
15
# File 'lib/dictum/html_writer.rb', line 13

def header_title
  @header_title
end

#output_dirObject (readonly)

Returns the value of attribute output_dir.



13
14
15
# File 'lib/dictum/html_writer.rb', line 13

def output_dir
  @output_dir
end

#output_fileObject (readonly)

Returns the value of attribute output_file.



13
14
15
# File 'lib/dictum/html_writer.rb', line 13

def output_file
  @output_file
end

#temp_jsonObject (readonly)

Returns the value of attribute temp_json.



13
14
15
# File 'lib/dictum/html_writer.rb', line 13

def temp_json
  @temp_json
end

#temp_pathObject (readonly)

Returns the value of attribute temp_path.



13
14
15
# File 'lib/dictum/html_writer.rb', line 13

def temp_path
  @temp_path
end

Instance Method Details

#writeObject



23
24
25
26
27
# File 'lib/dictum/html_writer.rb', line 23

def write
  Dir.mkdir(output_dir) unless Dir.exist?(output_dir)
  write_index
  write_pages
end