Class: S3Utils::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/s3_utils/path.rb

Instance Method Summary collapse

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_nameObject



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

#elementObject



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_bucketObject



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