Class: Gloss::Writer

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/gloss/writer.rb

Instance Method Summary collapse

Methods included from Utils

src_path_to_output_path, with_file_header

Constructor Details

#initialize(content, src_path, output_path = Pathname.new(src_path_to_output_path(src_path))) ⇒ Writer

Returns a new instance of Writer.



18
19
20
21
# File 'lib/gloss/writer.rb', line 18

def initialize(content, src_path, output_path = Pathname.new(src_path_to_output_path(src_path)))
  @content = content
  @output_path = output_path
end

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
# File 'lib/gloss/writer.rb', line 22

def run()
  unless       @output_path.parent
.exist?
    FileUtils.mkdir_p(@output_path.parent)
  end
  File.open(@output_path, "wb") { |file|
    file.puts(@content)
  }
end