Sha256: 9196e036a9134173d7dbc07e14be860f56b807a643a12c710246f2408a5862e3

Contents?: true

Size: 723 Bytes

Versions: 6

Compression:

Stored size: 723 Bytes

Contents

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

module FunWith
  module Files
    module StringBehavior
      def =~( rval )
        @path =~ rval
      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

6 entries across 6 versions & 1 rubygems

Version Path
fun_with_files-0.0.15 ./lib/fun_with/files/string_behavior.rb
fun_with_files-0.0.14 ./lib/fun_with/files/string_behavior.rb
fun_with_files-0.0.13 ./lib/fun_with/files/string_behavior.rb
fun_with_files-0.0.12 ./lib/fun_with/files/string_behavior.rb
fun_with_files-0.0.9 ./lib/fun_with/files/string_behavior.rb
fun_with_files-0.0.8 ./lib/fun_with/files/string_behavior.rb