Class: AzureBlob::BlobList

Inherits:
Object
  • Object
show all
Includes:
Enumerable, REXML
Defined in:
lib/azure_blob/blob_list.rb

Overview

Enumerator class to lazily iterate over a list of Blob keys.

Instance Method Summary collapse

Constructor Details

#initialize(fetcher) ⇒ BlobList

You should not instanciate this object directly, but obtain one when calling relevant methods of AzureBlob::Client.

Expects a callable object that takes an Azure API page marker as an argument and returns the raw body response of a call to the list blob endpoint.

Example:

fetcher = ->(marker) do
  uri.query = URI.encode_www_form(
    marker: marker,
    ...
  )
  response = Http.new(uri, signer:).get
end
AzureBlob::BlobList.new(fetcher)


28
29
30
# File 'lib/azure_blob/blob_list.rb', line 28

def initialize(fetcher)
  @fetcher = fetcher
end

Instance Method Details

#eachObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/azure_blob/blob_list.rb', line 36

def each
  loop do
    fetch
    current_page.each do |key|
      yield key
    end

    break unless marker
  end
end

#inspectObject



51
52
53
# File 'lib/azure_blob/blob_list.rb', line 51

def inspect
  to_a.inspect
end

#sizeObject



32
33
34
# File 'lib/azure_blob/blob_list.rb', line 32

def size
  to_a.size
end

#to_sObject



47
48
49
# File 'lib/azure_blob/blob_list.rb', line 47

def to_s
  to_a.to_s
end