Class: Backupsss::BackupBucket
- Inherits:
-
Object
- Object
- Backupsss::BackupBucket
- Defined in:
- lib/backupsss/backup_bucket.rb
Overview
A class for listing and sorting files in an s3 bucket
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ BackupBucket
constructor
A new instance of BackupBucket.
- #ls ⇒ Object
- #ls_rt ⇒ Object
- #ls_t ⇒ Object
- #rm(file) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ BackupBucket
Returns a new instance of BackupBucket.
8 9 10 11 |
# File 'lib/backupsss/backup_bucket.rb', line 8 def initialize(opts = {}) @dir = opts[:dir] @region = opts[:region] end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
6 7 8 |
# File 'lib/backupsss/backup_bucket.rb', line 6 def dir @dir end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
6 7 8 |
# File 'lib/backupsss/backup_bucket.rb', line 6 def region @region end |
Instance Method Details
#ls ⇒ Object
13 14 15 |
# File 'lib/backupsss/backup_bucket.rb', line 13 def ls list_objects.map(&:key) end |
#ls_rt ⇒ Object
21 22 23 |
# File 'lib/backupsss/backup_bucket.rb', line 21 def ls_rt ls_t.reverse end |
#ls_t ⇒ Object
17 18 19 |
# File 'lib/backupsss/backup_bucket.rb', line 17 def ls_t list_objects.sort_by(&:last_modified).map(&:key) end |
#rm(file) ⇒ Object
25 26 27 28 |
# File 'lib/backupsss/backup_bucket.rb', line 25 def rm(file) s3_client.delete_object(bucket: bucket, key: file) file end |