Class: Canistor::Subject
- Inherits:
-
Object
- Object
- Canistor::Subject
- Defined in:
- lib/canistor/subject.rb
Constant Summary collapse
- HOST_RE =
/\A([^\.]+\.)?(s3\.([^\.]+)|s3-([^\.]+))/
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(uri) ⇒ Subject
constructor
A new instance of Subject.
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
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
8 9 10 |
# File 'lib/canistor/subject.rb', line 8 def bucket @bucket end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
9 10 11 |
# File 'lib/canistor/subject.rb', line 9 def key @key end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
7 8 9 |
# File 'lib/canistor/subject.rb', line 7 def region @region end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
5 6 7 |
# File 'lib/canistor/subject.rb', line 5 def uri @uri end |