Sha256: 96a91ffa63c1c2c58de85e62301b62de2607281ae4221456d7fb1519b7aa11c3

Contents?: true

Size: 779 Bytes

Versions: 1

Compression:

Stored size: 779 Bytes

Contents

# Allow FilePaths to participate in some of the String-based mischief.

module FunWith
  module Files
    module StringBehavior
      def =~( rhs )
        @path =~ rhs
      end
      
      def !~( rhs )
        @path !~ rhs
      end
      
      def match( *args )
        @path.match( *args )
      end
      
      # gsub acts on the filepath, not the file contents
      def gsub( *args )
        @path.gsub(*args).fwf_filepath
      end
      
      def gsub!( *args )
        @path = @path.gsub(*args)
      end
      
      def scan( *args, &block )
        @path.scan( *args, &block )
      end
      
      # Lets it be a string when a string is called for.  Replacement argument in .gsub(), for example.
      def to_str
        @path.dup
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fun_with_files-0.0.18 ./lib/fun_with/files/string_behavior.rb