Class: Source2MD::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/source2md/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Generator

Returns a new instance of Generator.



5
6
7
# File 'lib/source2md/generator.rb', line 5

def initialize(params = {})
  @params = params
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



3
4
5
# File 'lib/source2md/generator.rb', line 3

def params
  @params
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/source2md/generator.rb', line 9

def call
  if !output_file
    puts to_md
  end

  if output_file
    temporarily_disable_write_protection do
      output_file.write(to_md)
      puts "write: #{output_file}"
    end
  end
end

#to_mdObject



22
23
24
25
26
# File 'lib/source2md/generator.rb', line 22

def to_md
  s = sections.collect(&:to_md) * "\n\n"
  s = TextHelper.blank_lines_squish(s)
  s = TextHelper.eol_enter(s)
end