Class: S3Utils::Path
- Inherits:
-
Object
- Object
- S3Utils::Path
- Defined in:
- lib/s3_utils/path.rb
Instance Method Summary collapse
- #bucket_name ⇒ Object
- #element ⇒ Object
-
#initialize(path) ⇒ Path
constructor
A new instance of Path.
- #path_without_bucket ⇒ Object
Constructor Details
#initialize(path) ⇒ Path
Returns a new instance of Path.
5 6 7 |
# File 'lib/s3_utils/path.rb', line 5 def initialize(path) @path = Pathname.new(path) end |
Instance Method Details
#bucket_name ⇒ Object
9 10 11 12 13 |
# File 'lib/s3_utils/path.rb', line 9 def bucket_name return '' if @path.to_s.empty? || @path.to_s == '.' element[0].to_s.empty? ? element[1] : element[0] end |
#element ⇒ Object
20 21 22 |
# File 'lib/s3_utils/path.rb', line 20 def element @element ||= @path.cleanpath.to_s.split(Pathname::SEPARATOR_PAT) end |
#path_without_bucket ⇒ Object
15 16 17 18 |
# File 'lib/s3_utils/path.rb', line 15 def path_without_bucket ele = element.drop_while(&:empty?).drop(1) File.join(ele) end |