Sha256: 353b08246ba5b1481edf52c4400576fca6d472f7e3fa90cb0af88e27f34d0299

Contents?: true

Size: 842 Bytes

Versions: 8

Compression:

Stored size: 842 Bytes

Contents

require 'nokogiri'

require 'ms/ident/pepxml/search_hit'

module Ms ; end
module Ms::Ident ; end
class Ms::Ident::Pepxml ; end

class Ms::Ident::Pepxml::SearchResult
  # an array of search_hits
  attr_accessor :search_hits

  # 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.
  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

  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

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ms-ident-0.1.1 lib/ms/ident/pepxml/search_result.rb
ms-ident-0.0.23 lib/ms/ident/pepxml/search_result.rb
ms-ident-0.0.22 lib/ms/ident/pepxml/search_result.rb
ms-ident-0.0.21 lib/ms/ident/pepxml/search_result.rb
ms-ident-0.0.20 lib/ms/ident/pepxml/search_result.rb
ms-ident-0.0.19 lib/ms/ident/pepxml/search_result.rb
ms-ident-0.0.18 lib/ms/ident/pepxml/search_result.rb
ms-ident-0.0.17 lib/ms/ident/pepxml/search_result.rb