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.



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

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.



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

def bucket
  @bucket
end

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

Instance Method Details

#objectObject



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

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