123456789_123456789_123456789_123456789_123456789_

Class: Gem::Package::IOSource

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Source
Instance Chain:
self, Source
Inherits: Gem::Package::Source
Defined in: lib/rubygems/package/io_source.rb

Overview

Supports reading and writing gems from/to a generic IO object. This is useful for other applications built on top of rubygems, such as rubygems.org.

This is a private class, do not depend on it directly. Instead, pass an IO object to new.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(io) ⇒ IOSource

[ GitHub ]

  
# File 'lib/rubygems/package/io_source.rb', line 14

def initialize io
  @io = io
end

Instance Attribute Details

#io (readonly)

[ GitHub ]

  
# File 'lib/rubygems/package/io_source.rb', line 12

attr_reader :io

#present?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rubygems/package/io_source.rb', line 30

def present?
  true
end

Instance Method Details

#path

[ GitHub ]

  
# File 'lib/rubygems/package/io_source.rb', line 42

def path
end

#start

[ GitHub ]

  
# File 'lib/rubygems/package/io_source.rb', line 18

def start
  @start ||= begin
    if io.pos > 0
      raise Gem::Package::Error, "Cannot read start unless IO is at start"
    end

    value = io.read 20
    io.rewind
    value
  end
end

#with_read_io {|io| ... }

Yields:

[ GitHub ]

  
# File 'lib/rubygems/package/io_source.rb', line 34

def with_read_io
  yield io
end

#with_write_io {|io| ... }

Yields:

[ GitHub ]

  
# File 'lib/rubygems/package/io_source.rb', line 38

def with_write_io
  yield io
end