Class: Canistor::Subject

Inherits:
Object
  • Object
show all
Defined in:
lib/canistor/subject.rb

Constant Summary collapse

HOST_RE =
/\A([^\.]+\.)?(s3\.([^\.]+)|s3-([^\.]+))/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ Subject

Returns a new instance of Subject.



13
14
15
16
17
18
19
20
21
22
# File 'lib/canistor/subject.rb', line 13

def initialize(uri)
  @uri = uri

  host_segments = HOST_RE.match(uri.host)
  path_segments = uri.path.split('/', 3)[1..-1] || []

  @region = parse_region(host_segments)
  @bucket = parse_bucket(host_segments, path_segments)
  @key = path_segments.empty? ? nil : path_segments.join('/')
end

Instance Attribute Details

#bucketObject (readonly)

Returns the value of attribute bucket.



8
9
10
# File 'lib/canistor/subject.rb', line 8

def bucket
  @bucket
end

#keyObject (readonly)

Returns the value of attribute key.



9
10
11
# File 'lib/canistor/subject.rb', line 9

def key
  @key
end

#regionObject (readonly)

Returns the value of attribute region.



7
8
9
# File 'lib/canistor/subject.rb', line 7

def region
  @region
end

#uriObject (readonly)

Returns the value of attribute uri.



5
6
7
# File 'lib/canistor/subject.rb', line 5

def uri
  @uri
end