Class: Sluice::Storage::S3::Location

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(s3_location) ⇒ Location

Returns a new instance of Location.

Raises:

  • (ArgumentError)


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

#bucketObject (readonly)

Returns the value of attribute bucket.



28
29
30
# File 'lib/sluice/storage/s3/location.rb', line 28

def bucket
  @bucket
end

#dirObject (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_pathObject



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_sObject



56
57
58
# File 'lib/sluice/storage/s3/location.rb', line 56

def to_s
  @s3_location
end