Class: Autility::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/autility/data.rb,
lib/autility/document.rb

Overview

Public: Represents a remote document we are interested in.

Examples

document = Document.new(url, :post, cookie, params)
document.save("~/utilities/endesa_11_2012.pdf")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, method = :get, cookie = nil, params = {}) ⇒ Document

Public: Initializes a new document.

url - The String url where we can get the document method - The String HTTP method to use. cookie - the session Cookie needed to access the url params - The Array of POST params needed to fetch it



15
16
17
18
19
# File 'lib/autility/data.rb', line 15

def initialize(url, params, cookie)
  @url    = url
  @params = params
  @cookie = cookie
end

Instance Attribute Details

Returns the value of attribute cookie.



10
11
12
# File 'lib/autility/document.rb', line 10

def cookie
  @cookie
end

#paramsObject (readonly)

Returns the value of attribute params.



10
11
12
# File 'lib/autility/document.rb', line 10

def params
  @params
end

#urlObject (readonly)

Returns the value of attribute url.



10
11
12
# File 'lib/autility/document.rb', line 10

def url
  @url
end

Instance Method Details

#save(path) ⇒ Object

Public: Fetches the document and saves it to a particular path.

path - The String path where we will save the document.

Returns nothing.



30
31
32
33
# File 'lib/autility/document.rb', line 30

def save(path)
  command = Command.build(@url, @method, @cookie, @params, path)
  system(command)
end