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

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


36
37
38
39
40
41
42
43
44
45
# File 'lib/sluice/storage/s3/location.rb', line 36

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.



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

def bucket
  @bucket
end

#dirObject (readonly)

Returns the value of attribute dir.



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

def dir
  @dir
end

Instance Method Details

#==(o) ⇒ Object Also known as: eql?



62
63
64
# File 'lib/sluice/storage/s3/location.rb', line 62

def ==(o)
  o.class == self.class && o.state == state
end

#dir_as_pathObject



48
49
50
51
52
53
54
# File 'lib/sluice/storage/s3/location.rb', line 48

def dir_as_path
  if @dir.length > 0
    return @dir+'/'
  else
    return ''
  end
end

#to_sObject



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

def to_s
  @s3_location
end