Class: WebCrawler::View::Xml

Inherits:
Base
  • Object
show all
Defined in:
lib/web_crawler/view/xml.rb

Instance Attribute Summary

Attributes inherited from Base

#input

Instance Method Summary collapse

Methods inherited from Base

#draw, #initialize

Constructor Details

This class inherits a constructor from WebCrawler::View::Base

Instance Method Details

#format(item) ⇒ Object



11
12
13
# File 'lib/web_crawler/view/xml.rb', line 11

def format(item)
  response_tag item.is_a?(Hash) ? item : Hash[@options[:headers].zip item]
end

#renderObject



6
7
8
9
# File 'lib/web_crawler/view/xml.rb', line 6

def render
  @options[:headers] ||= input.max_by(&:size).each_with_index.map { |_, index| "field_#{index+1}" }
  "<responses>#{pretty}#{super}</responses>"
end