Class: Gem::Package::IOSource
- 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 ‘Gem::Package.new`.
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
:nodoc: all.
Instance Method Summary collapse
-
#initialize(io) ⇒ IOSource
constructor
A new instance of IOSource.
- #path ⇒ Object
- #present? ⇒ Boolean
- #start ⇒ Object
- #with_read_io {|io| ... } ⇒ Object
- #with_write_io {|io| ... } ⇒ Object
Constructor Details
#initialize(io) ⇒ IOSource
Returns a new instance of IOSource.
13 14 15 |
# File 'lib/rubygems/package/io_source.rb', line 13 def initialize(io) @io = io end |
Instance Attribute Details
#io ⇒ Object (readonly)
:nodoc: all
11 12 13 |
# File 'lib/rubygems/package/io_source.rb', line 11 def io @io end |
Instance Method Details
#path ⇒ Object
41 42 |
# File 'lib/rubygems/package/io_source.rb', line 41 def path end |
#present? ⇒ Boolean
29 30 31 |
# File 'lib/rubygems/package/io_source.rb', line 29 def present? true end |
#start ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubygems/package/io_source.rb', line 17 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| ... } ⇒ Object
33 34 35 |
# File 'lib/rubygems/package/io_source.rb', line 33 def with_read_io yield io end |
#with_write_io {|io| ... } ⇒ Object
37 38 39 |
# File 'lib/rubygems/package/io_source.rb', line 37 def with_write_io yield io end |