class Docdown::CodeCommands::Write
Public Class Methods
new(filename)
click to toggle source
# File lib/docdown/code_commands/write.rb, line 4 def initialize(filename) @filename = filename @dir = File.expand_path("../", @filename) end
Public Instance Methods
call()
click to toggle source
# File lib/docdown/code_commands/write.rb, line 14 def call puts "writing to : #{@filename}" FileUtils.mkdir_p(@dir) File.open(@filename, "w") do |f| f.write(contents) end contents end
to_md()
click to toggle source
todo diff file if it already exists
# File lib/docdown/code_commands/write.rb, line 10 def to_md "In file `#{@filename}` add:\n#{contents}" end