Class: Mspire::Ident::Pepxml::SearchResult
- Inherits:
-
Object
- Object
- Mspire::Ident::Pepxml::SearchResult
- Defined in:
- lib/mspire/ident/pepxml/search_result.rb
Instance Attribute Summary collapse
-
#search_hits ⇒ Object
an array of search_hits.
Instance Method Summary collapse
-
#initialize(search_hits = [], &block) ⇒ SearchResult
constructor
if block given, then yields an empty search_hits array.
- #to_xml(builder = nil) ⇒ Object
Constructor Details
#initialize(search_hits = [], &block) ⇒ SearchResult
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.
16 17 18 19 20 21 22 |
# 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 |
Instance Attribute Details
#search_hits ⇒ Object
an array of search_hits
11 12 13 |
# File 'lib/mspire/ident/pepxml/search_result.rb', line 11 def search_hits @search_hits end |
Instance Method Details
#to_xml(builder = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# 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 |