Class: Sluice::Storage::S3::Location
- Inherits:
-
Object
- Object
- Sluice::Storage::S3::Location
- Defined in:
- lib/sluice/storage/s3/location.rb
Overview
Class to describe an S3 location TODO: if we are going to require 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.
Instance Method Summary collapse
- #==(o) ⇒ Object (also: #eql?)
- #dir_as_path ⇒ Object
-
#initialize(s3_location) ⇒ Location
constructor
A new instance of Location.
- #to_s ⇒ Object
Constructor Details
#initialize(s3_location) ⇒ Location
Returns a new instance of Location.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/sluice/storage/s3/location.rb', line 35 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] self end |
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
28 29 30 |
# File 'lib/sluice/storage/s3/location.rb', line 28 def bucket @bucket end |
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
28 29 30 |
# File 'lib/sluice/storage/s3/location.rb', line 28 def dir @dir end |
Instance Method Details
#==(o) ⇒ Object Also known as: eql?
61 62 63 |
# File 'lib/sluice/storage/s3/location.rb', line 61 def ==(o) o.class == self.class && o.state == state end |
#dir_as_path ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/sluice/storage/s3/location.rb', line 47 def dir_as_path if @dir.length > 0 return @dir+'/' else return '' end end |
#to_s ⇒ Object
56 57 58 |
# File 'lib/sluice/storage/s3/location.rb', line 56 def to_s @s3_location end |