Sha256: ebfea63150fd49b5ac7bd442d7361a8b55525450e04d8031cd3460291b8b4ae7
Contents?: true
Size: 1.06 KB
Versions: 23
Compression:
Stored size: 1.06 KB
Contents
module SugarHigh 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 end
Version data entries
23 entries across 23 versions & 1 rubygems