Sha256: 1de4446ce9449bc8b0edebd92f76e719b844a298cb18789dfa1e14c96d363753

Contents?: true

Size: 1015 Bytes

Versions: 13

Compression:

Stored size: 1015 Bytes

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(fd, mode = nil, options = Backports::Undefined)
        mode = Backports.combine_mode_and_option(mode, options)
        # Can't backport autoclose, {internal|external|}encoding
        if block_given?
          open_without_options_hash(fd, mode){|f| yield f}
        else
          open_without_options_hash(fd, mode)
        end
      end

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

  Backports.alias_method self, :ungetbyte, :ungetc
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
backports-2.6.6 lib/backports/1.9.1/io.rb
backports-2.6.5 lib/backports/1.9.1/io.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/backports-2.6.4/lib/backports/1.9.1/io.rb
backports-2.6.4 lib/backports/1.9.1/io.rb
backports-2.6.3 lib/backports/1.9.1/io.rb
backports-2.6.2 lib/backports/1.9.1/io.rb
backports-2.6.1 lib/backports/1.9.1/io.rb
backports-2.6.0 lib/backports/1.9.1/io.rb
backports-2.5.3 lib/backports/1.9.1/io.rb
backports-2.5.2 lib/backports/1.9.1/io.rb
backports-2.5.1 lib/backports/1.9.1/io.rb
backports-2.5.0 lib/backports/1.9.1/io.rb
backports-2.4.0 lib/backports/1.9.1/io.rb