Module: HTTParty::ResponseIds

Defined in:
lib/httparty/response/ids.rb

Instance Method Summary collapse

Instance Method Details

#idsObject

For ESearch, add convenience method that parses ids and converts to array of integers. Only works if either no retern mode specified or if it is :xml.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/httparty/response/ids.rb', line 7

def ids
  if parse_ids?
    return @ids if @ids
    id_list = parsed_response['eSearchResult']['IdList']
    if id_list
      id_content = id_list['Id']
      id_content = [id_content].flatten
      @ids = id_content.map(&:to_i)
    else
      @ids = []
    end
  end
end