Class: Hasta::S3File
- Inherits:
-
Object
- Object
- Hasta::S3File
- Extended by:
- Forwardable
- Defined in:
- lib/hasta/s3_file.rb
Overview
Hasta’s interface to the File objects returned by Fog
Class Method Summary collapse
Instance Method Summary collapse
- #each_line ⇒ Object
- #fingerprint ⇒ Object
-
#initialize(s3_file) ⇒ S3File
constructor
A new instance of S3File.
- #remote? ⇒ Boolean
- #s3_uri ⇒ Object
Constructor Details
#initialize(s3_file) ⇒ S3File
Returns a new instance of S3File.
26 27 28 |
# File 'lib/hasta/s3_file.rb', line 26 def initialize(s3_file) @s3_file = s3_file end |
Class Method Details
.wrap(s3_file) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/hasta/s3_file.rb', line 16 def self.wrap(s3_file) if self === s3_file s3_file elsif s3_file.nil? nil else new(s3_file) end end |
.wrap_files(s3_files) ⇒ Object
12 13 14 |
# File 'lib/hasta/s3_file.rb', line 12 def self.wrap_files(s3_files) s3_files.map { |s3_file| wrap(s3_file) } end |
Instance Method Details
#each_line ⇒ Object
46 47 48 49 50 |
# File 'lib/hasta/s3_file.rb', line 46 def each_line return enum_for(:each_line) unless block_given? StringIO.new(s3_file.body).each_line { |line| yield line } end |
#fingerprint ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/hasta/s3_file.rb', line 34 def fingerprint @fingerprint ||= if s3_file.respond_to? :etag s3_file.etag else Digest::MD5.hexdigest(body) end end |
#remote? ⇒ Boolean
42 43 44 |
# File 'lib/hasta/s3_file.rb', line 42 def remote? !(Fog::Storage::Local::File === s3_file) end |