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.
14 15 16 |
# File 'lib/rubygems/package/io_source.rb', line 14 def initialize(io) @io = io end |
Instance Attribute Details
#io ⇒ Object (readonly)
:nodoc: all
12 13 14 |
# File 'lib/rubygems/package/io_source.rb', line 12 def io @io end |
Instance Method Details
#path ⇒ Object
42 43 |
# File 'lib/rubygems/package/io_source.rb', line 42 def path end |
#present? ⇒ Boolean
30 31 32 |
# File 'lib/rubygems/package/io_source.rb', line 30 def present? true end |
#start ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# 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| ... } ⇒ Object
34 35 36 |
# File 'lib/rubygems/package/io_source.rb', line 34 def with_read_io yield io end |
#with_write_io {|io| ... } ⇒ Object
38 39 40 |
# File 'lib/rubygems/package/io_source.rb', line 38 def with_write_io yield io end |