Class: AzureBlob::Tags

Inherits:
Object
  • Object
show all
Defined in:
lib/azure_blob/tags.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tags = nil) ⇒ Tags

Returns a new instance of Tags.



16
17
18
# File 'lib/azure_blob/tags.rb', line 16

def initialize(tags = nil)
  @tags = tags || {}
end

Class Method Details

.from_response(response) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/azure_blob/tags.rb', line 5

def self.from_response(response)
  document = REXML::Document.new(response)
  tags = {}
  document.elements.each("Tags/TagSet/Tag") do |tag|
    key = tag.elements["Key"].text
    value = tag.elements["Value"].text
    tags[key] = value
  end
  new(tags)
end

Instance Method Details

#headersObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/azure_blob/tags.rb', line 20

def headers
  return {} if @tags.empty?

  {
    "x-ms-tags":
    @tags.map do |key, value|
      %(#{key}=#{value})
    end.join("&"),
  }
end

#to_hObject



31
32
33
# File 'lib/azure_blob/tags.rb', line 31

def to_h
  @tags
end