module HTTParty::ResponseIds

Public Instance Methods

ids() click to toggle source

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.

# 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

Private Instance Methods

parse_ids?() click to toggle source

Parse only if this is an ESearch request and in xml format.

# File lib/httparty/response/ids.rb, line 24
def parse_ids?
  esearch_request? && (retmode.nil? || xml?)
end