class Proxtopus::Response

Attributes

page[R]
proxies[R]
resource[R]

Public Class Methods

new(page, resource) click to toggle source
# File lib/proxtopus/response.rb, line 6
def initialize(page, resource)
  #puts "to response"
  #raise ArgumentError, "Response.new() expects page to be of type Mechanize::Page!" if !page.is_a?(Mechanize::Page)
  #raise ArgumentError, "Response.new() expects format to be of type Symbol!" if !format.is_a?(Symbol)
  #raise ArgumentError, "Response.new() expects elements to be of type Symbol!" if !format.is_a?(Symbol)
  
  @page = page
  @resource = resource
  #@body = page
  #@format = format
  #@elements = elements
  
  if resource.format == :json
    @proxies = Parser.json(page.body, resource.elements)
  elsif resource.format == :xml
    @proxies = Parser.xml(page.body, resource.elements)
  #elsif format == :rss
  #  @parsed = Parser.rss(@body, @elements)
  else
    raise ArgumentError, "Format #{resource.format} is currenly unsupported... consider adding it =]"
  end
  
  #puts "[@proxies in Response]"
  #puts @proxies.inspect
  #puts
  #puts
  #gets
  @proxies
end