Class: Puree::XMLExtractor::Collection

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

Overview

Collection XML extractor.

Instance Method Summary collapse

Methods inherited from Base

#xpath_query_for_multi_value, #xpath_query_for_single_value

Constructor Details

#initialize(xml:) ⇒ Collection

Returns a new instance of Collection.



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

def initialize(xml:)
  super
end

Instance Method Details

#countFixnum

Records available in collection.

Returns:

  • (Fixnum)


16
17
18
# File 'lib/puree/xml_extractor/collection.rb', line 16

def count
  @doc.xpath('//count').text.strip.to_i
end

#get_data?Boolean

Is there any data after get?

Returns:

  • (Boolean)


32
33
34
# File 'lib/puree/xml_extractor/collection.rb', line 32

def get_data?
  count >= 1 ? true : false
end

#uuidsArray<String>

Resource UUIDs in collection response.

Returns:

  • (Array<String>)


23
24
25
26
27
28
# File 'lib/puree/xml_extractor/collection.rb', line 23

def uuids
  arr = []
  xpath_result = @doc.xpath '//renderedItem/@renderedContentUUID'
  xpath_result.each { |i| arr << i.text.strip }
  arr
end