123456789_123456789_123456789_123456789_123456789_

Class: Gem::Package::FileSource

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/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 new.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(path) ⇒ FileSource

[ GitHub ]

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

def initialize(path)
  @path = path
end

Instance Attribute Details

#path (readonly)

[ GitHub ]

  
# File 'lib/rubygems/package/file_source.rb', line 10

attr_reader :path

#present?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rubygems/package/file_source.rb', line 20

def present?
  File.exist? path
end

Instance Method Details

#start

[ GitHub ]

  
# File 'lib/rubygems/package/file_source.rb', line 16

def start
  @start ||= File.read path, 20
end

#with_read_io(&block)

[ GitHub ]

  
# File 'lib/rubygems/package/file_source.rb', line 28

def with_read_io(&block)
  File.open path, "rb", &block
end

#with_write_io(&block)

[ GitHub ]

  
# File 'lib/rubygems/package/file_source.rb', line 24

def with_write_io(&block)
  File.open path, "wb", &block
end