Method: Azure::Storage::Blob::Serialization.block_list_from_xml

Defined in:
lib/azure/storage/blob/serialization.rb

.block_list_from_xml(xml) ⇒ Object



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/azure/storage/blob/serialization.rb', line 288

def self.block_list_from_xml(xml)
  xml = slopify(xml)
  expect_node("BlockList", xml)

  block_list = {
    committed: [],
    uncommitted: []
  }

  if ((xml > "CommittedBlocks") > "Block").any?
    if xml.CommittedBlocks.Block.count == 0
      add_block(:committed, xml.CommittedBlocks.Block, block_list)
    else
      xml.CommittedBlocks.Block.each { |block_node|
        add_block(:committed, block_node, block_list)
      }
    end
  end

  return block_list unless (xml > "UncommittedBlocks")

  if ((xml > "UncommittedBlocks") > "Block").any?
    if xml.UncommittedBlocks.Block.count == 0
      add_block(:uncommitted, xml.UncommittedBlocks.Block, block_list)
    else
      xml.UncommittedBlocks.Block.each { |block_node|
        add_block(:uncommitted, block_node, block_list)
      }
    end
  end

  block_list
end