class Mspire::Ident::Pepxml::SearchResult

Attributes

search_hits[RW]

an array of search_hits

Public Class Methods

new(search_hits = [], &block) click to toggle source

if block given, then yields an empty search_hits array. For consistency with other objects, will also take a hash that has the key :search_hits and the value an array.

# File lib/mspire/ident/pepxml/search_result.rb, line 16
def initialize(search_hits = [], &block)
  @search_hits = search_hits
  if search_hits.is_a?(Hash)
    @search_hits = search_hits[:search_hits]
  end
  block.call(@search_hits) if block
end

Public Instance Methods

to_xml(builder=nil) click to toggle source
# File lib/mspire/ident/pepxml/search_result.rb, line 24
def to_xml(builder=nil)
  xmlb = builder || Nokogiri::XML::Builder.new
  builder.search_result do |xmlb|
    search_hits.each do |sh|
      sh.to_xml(xmlb)
    end
  end
  builder || xmlb.doc.root.to_xml 
end