Class: Source2MD::Generator
- Inherits:
-
Object
- Object
- Source2MD::Generator
- Defined in:
- lib/source2md/generator.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(params = {}) ⇒ Generator
constructor
A new instance of Generator.
- #to_md ⇒ Object
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
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'lib/source2md/generator.rb', line 3 def params @params end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/source2md/generator.rb', line 9 def call if !output_file puts to_md end if output_file if output_file.exist? FileUtils.chmod("a+w", output_file) end output_file.write(to_md) if Source2MD.readonly FileUtils.chmod("a-w", output_file) end puts "write: #{output_file}" end end |
#to_md ⇒ Object
26 27 28 29 30 |
# File 'lib/source2md/generator.rb', line 26 def to_md s = sections.collect(&:to_md) * "\n\n" s = TextHelper.blank_lines_squish(s) s = TextHelper.add_newline_at_end_of_text(s) end |