Sha256: e7066157a786351943130a75e10a44ed9dbc70f43de3f7efdd3e1716ab487bc6

Contents?: true

Size: 842 Bytes

Versions: 15

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

15 entries across 15 versions & 1 rubygems

Version Path
mspire-0.6.26 lib/ms/ident/pepxml/search_result.rb
mspire-0.6.25 lib/ms/ident/pepxml/search_result.rb
mspire-0.6.24 lib/ms/ident/pepxml/search_result.rb
mspire-0.6.22 lib/ms/ident/pepxml/search_result.rb
mspire-0.6.21 lib/ms/ident/pepxml/search_result.rb
mspire-0.6.20 lib/ms/ident/pepxml/search_result.rb
mspire-0.6.19 lib/ms/ident/pepxml/search_result.rb
mspire-0.6.18 lib/ms/ident/pepxml/search_result.rb
mspire-0.6.12 lib/ms/ident/pepxml/search_result.rb
mspire-0.6.11 lib/ms/ident/pepxml/search_result.rb
mspire-0.6.9 lib/ms/ident/pepxml/search_result.rb
mspire-0.6.7 lib/ms/ident/pepxml/search_result.rb
mspire-0.6.6 lib/ms/ident/pepxml/search_result.rb
mspire-0.6.2 lib/ms/ident/pepxml/search_result.rb
mspire-0.6.1 lib/ms/ident/pepxml/search_result.rb