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

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

Instance Method Summary collapse

Constructor Details

#initialize(s3_location) ⇒ Location

Parameters:

s3location

the s3 location config string e.g. “bucket/directory”

Raises:

  • (ArgumentError)


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

#bucketObject (readonly)

Returns the value of attribute bucket.



36
37
38
# File 'lib/sluice/storage/s3.rb', line 36

def bucket
  @bucket
end

#dirObject (readonly)

Returns the value of attribute dir.



36
37
38
# File 'lib/sluice/storage/s3.rb', line 36

def dir
  @dir
end

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



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_sObject



58
59
60
# File 'lib/sluice/storage/s3.rb', line 58

def to_s
  @s3_location
end