# File lib/backports/1.9.1/io.rb, line 3 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
Standard in Ruby 1.9.3 See official documentation This method does support an options hash, see bugs.ruby-lang.org/issues/5782
# File lib/backports/1.9.3/io.rb, line 29 def binwrite(name, string, offset = nil, options = Backports::Undefined) Backports.write(true, name, string, offset, options) end
# File lib/backports/1.9.1/io.rb, line 17 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
# File lib/backports/1.9.1/io.rb, line 10 def try_convert(obj) Backports.try_convert(obj, IO, :to_io) end
Standard in Ruby 1.9.3 See official documentation
# File lib/backports/1.9.3/io.rb, line 23 def write(name, string, offset = nil, options = Backports::Undefined) Backports.write(false, name, string, offset, options) end
Standard in Ruby 1.9.3 See official documentation We're only for a platform not implementing advise, so we return nil.
# File lib/backports/1.9.3/io.rb, line 4 def advise(advice, offset=0, len=0) case advice when :normal, :sequential, :random, :willneed, :dontneed, :noreuse return nil when Symbol raise NotImplementedError, "Unsupported advice #{advice}" else raise TypeError, "advice must be a Symbol" end end
# File lib/backports/1.8.7/io.rb, line 9 def each_char return to_enum(:each_char) unless block_given? if $KCODE == "UTF-8" lookup = 7.downto(4) while c = read(1) do n = c[0] leftmost_zero_bit = lookup.find{|i| n[i].zero? } case leftmost_zero_bit when 7 # ASCII yield c when 6 # UTF 8 complementary characters next # Encoding error, ignore else more = read(6-leftmost_zero_bit) break unless more yield c+more end end else while s = read(1) yield s end end self end
Generated with the Darkfish Rdoc Generator 2.