Sha256: 1925f48d5dbea82c862bf51f2c52eef001acce05b583ab45f2f5abf4f30d7f2e

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

Contents

class IO
  class << self
    def binread(file, *arg)
      raise ArgumentError, "wrong number of arguments (#{1+arg.size} for 1..3)" unless arg.size < 3
      File.open(Backports.convert_to_path(file),"rb") do |f|
        f.read(*arg)
      end
    end unless method_defined? :binread

    def try_convert(obj)
      Backports.try_convert(obj, IO, :to_io)
    end unless method_defined? :try_convert

    begin
      File.open(__FILE__) { |f| IO.open(f.fileno, :mode => 'r').close }
    rescue StandardError
      def open_with_options_hash(*args)
        if args.size > 2 || args[1].is_a?(Hash)
          fd, mode, options = (args << Backports::Undefined)
          args = [fd, Backports.combine_mode_and_option(mode, options)]
        end
        if block_given?
          open_without_options_hash(*args){|f| yield f}
        else
          open_without_options_hash(*args)
        end
      end

      Backports.alias_method_chain self, :open, :options_hash
    end
  end

  Backports.alias_method self, :ungetbyte, :ungetc
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
backports-3.0.3 lib/backports/1.9.1/io.rb
backports-3.0.2 lib/backports/1.9.1/io.rb
backports-3.0.1 lib/backports/1.9.1/io.rb
backports-3.0.0 lib/backports/1.9.1/io.rb
backports-2.8.2 lib/backports/1.9.1/io.rb
backports-2.8.1 lib/backports/1.9.1/io.rb
backports-2.8.0 lib/backports/1.9.1/io.rb
backports-2.7.1 lib/backports/1.9.1/io.rb
backports-2.7.0 lib/backports/1.9.1/io.rb
backports-2.6.7 lib/backports/1.9.1/io.rb