Class: Puree::XMLExtractor::Download

Inherits:
Base
  • Object
show all
Defined in:
lib/puree/xml_extractor/download.rb

Overview

Download XML extractor.

Instance Method Summary collapse

Methods inherited from Base

#xpath_query_for_multi_value, #xpath_query_for_single_value

Constructor Details

#initialize(xml:) ⇒ Download

Returns a new instance of Download.



9
10
11
12
# File 'lib/puree/xml_extractor/download.rb', line 9

def initialize(xml:)
  @resource_type = :download
  super
end

Instance Method Details

#get_data?Boolean

Is there any data after get?

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/puree/xml_extractor/download.rb', line 33

def get_data?
  # TO DO Inefficient!
  statistics.size ? true : false
end

#statisticsArray<Puree::Model::DownloadHeader>

Statistic

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/puree/xml_extractor/download.rb', line 17

def statistics
  path = "#{service_response_name}/downloadCount"
  xpath_result = @doc.xpath(path)
  data_arr = []
  xpath_result.each { |i|
    model = Puree::Model::DownloadHeader.new
    model.uuid = i.attr('uuid').strip
    model.count = i.attr('downloads').strip.to_i
    data_arr << model
  }
  data_arr.uniq { |d| d.uuid }
end