Class: FileLocator::S3File

Inherits:
Object
  • Object
show all
Defined in:
lib/file_locator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ S3File

Returns a new instance of S3File.



10
11
12
13
14
# File 'lib/file_locator.rb', line 10

def initialize(uri)
  uri = Addressable::URI.parse(uri)
  @bucket = URI.decode(uri.host)
  @key = URI.decode(uri.path).sub(%r(^/*(.+)/*$),'\1')
end

Instance Attribute Details

#bucketObject (readonly)

Returns the value of attribute bucket.



8
9
10
# File 'lib/file_locator.rb', line 8

def bucket
  @bucket
end

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/file_locator.rb', line 8

def key
  @key
end

Instance Method Details

#objectObject



16
17
18
# File 'lib/file_locator.rb', line 16

def object
  @object ||= Aws::S3::Object.new(bucket_name: bucket, key: key)
end