Class: Dictum::MarkdownWriter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output_path, temp_path, config) ⇒ MarkdownWriter

Returns a new instance of MarkdownWriter.



7
8
9
10
11
12
13
# File 'lib/dictum/markdown_writer.rb', line 7

def initialize(output_path, temp_path, config)
  @output_path = "#{output_path}.md"
  File.delete(@output_path) if File.exist?(@output_path)
  @temp_path = temp_path
  @temp_json = JSON.parse(File.read(temp_path))
  @config = config
end

Instance Attribute Details

#output_fileObject (readonly)

Returns the value of attribute output_file.



5
6
7
# File 'lib/dictum/markdown_writer.rb', line 5

def output_file
  @output_file
end

#output_pathObject (readonly)

Returns the value of attribute output_path.



5
6
7
# File 'lib/dictum/markdown_writer.rb', line 5

def output_path
  @output_path
end

#temp_jsonObject (readonly)

Returns the value of attribute temp_json.



5
6
7
# File 'lib/dictum/markdown_writer.rb', line 5

def temp_json
  @temp_json
end

#temp_pathObject (readonly)

Returns the value of attribute temp_path.



5
6
7
# File 'lib/dictum/markdown_writer.rb', line 5

def temp_path
  @temp_path
end

Instance Method Details

#writeObject



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

def write
  @output_file = File.open(output_path, 'a+')
  write_index
  write_temp_path
  write_error_codes
  output_file.close
end