Class: Stashify::Directory::Microsoft::Azure::Storage::Blob
- Inherits:
-
Stashify::Directory
- Object
- Stashify::Directory
- Stashify::Directory::Microsoft::Azure::Storage::Blob
- Defined in:
- lib/stashify/directory/microsoft/azure/storage/blob.rb
Overview
An implementation for interacting with Azure Blob Storage as if they had directories with “/” as a path separator. In addition to a path, it also needs a Azure::Storage::Blob::BlobService and Azure::Storage::Blob::Container::Container objects representing the container the file resides within.
Instance Attribute Summary collapse
-
#container ⇒ Object
readonly
Returns the value of attribute container.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #blobs ⇒ Object
- #directory(name) ⇒ Object
- #directory?(name) ⇒ Boolean
- #exists?(name) ⇒ Boolean
- #file(name) ⇒ Object
- #files ⇒ Object
-
#initialize(client:, container:, path:) ⇒ Blob
constructor
A new instance of Blob.
- #parent ⇒ Object
Constructor Details
#initialize(client:, container:, path:) ⇒ Blob
Returns a new instance of Blob.
21 22 23 24 25 |
# File 'lib/stashify/directory/microsoft/azure/storage/blob.rb', line 21 def initialize(client:, container:, path:) @client = client @container = container super(path: path) end |
Instance Attribute Details
#container ⇒ Object (readonly)
Returns the value of attribute container.
19 20 21 |
# File 'lib/stashify/directory/microsoft/azure/storage/blob.rb', line 19 def container @container end |
Instance Method Details
#==(other) ⇒ Object
81 82 83 |
# File 'lib/stashify/directory/microsoft/azure/storage/blob.rb', line 81 def ==(other) self.class == other.class && @container == other.container && path == other.path end |
#blobs ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/stashify/directory/microsoft/azure/storage/blob.rb', line 45 def blobs @client.list_blobs( @container.name, prefix: path_of(""), delimiter: "/", ) end |
#directory(name) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/stashify/directory/microsoft/azure/storage/blob.rb', line 61 def directory(name) Stashify::Directory::Microsoft::Azure::Storage::Blob.new( client: @client, container: @container, path: ::File.join(path, name), ) end |
#directory?(name) ⇒ Boolean
53 54 55 56 57 58 59 |
# File 'lib/stashify/directory/microsoft/azure/storage/blob.rb', line 53 def directory?(name) !@client.list_blobs( @container.name, prefix: path_of(name, ""), delimiter: "/", ).empty? end |
#exists?(name) ⇒ Boolean
69 70 71 |
# File 'lib/stashify/directory/microsoft/azure/storage/blob.rb', line 69 def exists?(name) file(name).exists? end |
#file(name) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/stashify/directory/microsoft/azure/storage/blob.rb', line 73 def file(name) Stashify::File::Microsoft::Azure::Storage::Blob.new( client: @client, container: @container, path: path_of(name), ) end |