class Rundoc::CodeCommand::FileCommand::Remove
Public Class Methods
Source
# File lib/rundoc/code_command/file_command/remove.rb, line 5 def initialize(filename) @filename = filename end
Public Instance Methods
Source
# File lib/rundoc/code_command/file_command/remove.rb, line 19 def call(env = {}) puts "Deleting '#{contents.strip}' from #{filename}" raise "#{filename} does not exist" unless File.exist?(filename) regex = /^\s*#{Regexp.quote(contents)}/ doc = File.read(filename) doc.sub!(regex, "") File.write(filename, doc) contents end
Source
# File lib/rundoc/code_command/file_command/remove.rb, line 9 def to_md(env) if env[:commands].any? { |c| c[:object].not_hidden? } raise "Must call remove in its own code section" end env[:before] << "In file `#{filename}` remove:" env[:before] << NEWLINE nil end