Class: Gem::Package::FileSource
- Defined in:
 - lib/rubygems/package/file_source.rb
 
Overview
The primary source of gems is a file on disk, including all usages internal to rubygems.
This is a private class, do not depend on it directly. Instead, pass a path object to ‘Gem::Package.new`.
Instance Attribute Summary collapse
- 
  
    
      #path  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
:nodoc: all.
 
Instance Method Summary collapse
- 
  
    
      #initialize(path)  ⇒ FileSource 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of FileSource.
 - #present? ⇒ Boolean
 - #start ⇒ Object
 - #with_read_io(&block) ⇒ Object
 - #with_write_io(&block) ⇒ Object
 
Constructor Details
#initialize(path) ⇒ FileSource
Returns a new instance of FileSource.
      13 14 15  | 
    
      # File 'lib/rubygems/package/file_source.rb', line 13 def initialize(path) @path = path end  | 
  
Instance Attribute Details
#path ⇒ Object (readonly)
:nodoc: all
      11 12 13  | 
    
      # File 'lib/rubygems/package/file_source.rb', line 11 def path @path end  | 
  
Instance Method Details
#present? ⇒ Boolean
      21 22 23  | 
    
      # File 'lib/rubygems/package/file_source.rb', line 21 def present? File.exist? path end  | 
  
#start ⇒ Object
      17 18 19  | 
    
      # File 'lib/rubygems/package/file_source.rb', line 17 def start @start ||= File.read path, 20 end  | 
  
#with_read_io(&block) ⇒ Object
      29 30 31  | 
    
      # File 'lib/rubygems/package/file_source.rb', line 29 def with_read_io(&block) File.open path, "rb", &block end  | 
  
#with_write_io(&block) ⇒ Object
      25 26 27  | 
    
      # File 'lib/rubygems/package/file_source.rb', line 25 def with_write_io(&block) File.open path, "wb", &block end  |