Sha256: 9b564d87f17a49d0069bb5ed032bda76d0e4d640eee25d87156f4c8e05708a07
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
module FileMutate module RemoveContent 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 alias_method :remove, :remove_content module ClassMethods def remove_from file_name, content=nil, &block content ||= yield replace_content_from file_name, :content => content, :with => '', &block end def remove_content_from file_name, options = {}, &block replace_content_from file_name, options.merge(:with => ''), &block end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
file_mutate-0.1.3 | lib/file_mutate/remove_content.rb |
file_mutate-0.1.2 | lib/file_mutate/remove_content.rb |