Class: Sluice::Storage::S3::Location
- Inherits:
-
Object
- Object
- Sluice::Storage::S3::Location
- Defined in:
- lib/sluice/storage/s3.rb
Overview
Class to describe an S3 location TODO: if we are going to impose trailing line-breaks on buckets, maybe we should make that clearer?
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#s3location ⇒ Object
readonly
Returns the value of attribute s3location.
Instance Method Summary collapse
- #dir_as_path ⇒ Object
-
#initialize(s3_location) ⇒ Location
constructor
- Parameters:
s3location
-
the s3 location config string e.g.
- Parameters:
- #to_s ⇒ Object
Constructor Details
#initialize(s3_location) ⇒ Location
Parameters:
s3location
-
the s3 location config string e.g. “bucket/directory”
40 41 42 43 44 45 46 47 48 |
# File 'lib/sluice/storage/s3.rb', line 40 def initialize(s3_location) @s3_location = s3_location s3_location_match = s3_location.match('^s3n?://([^/]+)/?(.*)/$') raise ArgumentError, 'Bad S3 location %s' % s3_location unless s3_location_match @bucket = s3_location_match[1] @dir = s3_location_match[2] end |
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
36 37 38 |
# File 'lib/sluice/storage/s3.rb', line 36 def bucket @bucket end |
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
36 37 38 |
# File 'lib/sluice/storage/s3.rb', line 36 def dir @dir end |
#s3location ⇒ Object (readonly)
Returns the value of attribute s3location.
36 37 38 |
# File 'lib/sluice/storage/s3.rb', line 36 def s3location @s3location end |
Instance Method Details
#dir_as_path ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/sluice/storage/s3.rb', line 50 def dir_as_path if @dir.length > 0 return @dir+'/' else return '' end end |
#to_s ⇒ Object
58 59 60 |
# File 'lib/sluice/storage/s3.rb', line 58 def to_s @s3_location end |