module FileMutate::RemoveContent

Public Instance Methods

remove(options=nil, &block)
Alias for: remove_content
remove_content(options=nil) { |: opt_str| ... } click to toggle source
# File lib/file_mutate/remove_content.rb, line 3
def remove_content options=nil, &block
  opt_str = case options
            when String
              options
            when Hash
              content = options[:content] || options[:where]
              raise ArgumentError, "Bad :content value in Hash" if !content || content.strip.empty?
              content.strip
            else
              raise ArgumentError, "non-block argument must be either String or Hash with a :content option" if !block
            end
  content = block ? yield : opt_str

  File.remove_content_from self.path, :content => content, :with => '', &block
end
Also aliased as: remove