Class: Request
- Inherits:
-
Object
- Object
- Request
- Defined in:
- lib/request.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#time_on_page ⇒ Object
readonly
Returns the value of attribute time_on_page.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #do_request! ⇒ Object
-
#initialize(url, options = {}) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(url, options = {}) ⇒ Request
Returns a new instance of Request.
17 18 19 20 21 22 23 |
# File 'lib/request.rb', line 17 def initialize(url, = {}) @time_on_page = [:time_on_page] || 4 @url = ([:host] || "") + url @method = [:method] || :get @params = [:params] || {} @browser = [:browser] #|| Mechanize.new end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method
14 15 16 |
# File 'lib/request.rb', line 14 def method @method end |
#time_on_page ⇒ Object (readonly)
Returns the value of attribute time_on_page
14 15 16 |
# File 'lib/request.rb', line 14 def time_on_page @time_on_page end |
#url ⇒ Object (readonly)
Returns the value of attribute url
14 15 16 |
# File 'lib/request.rb', line 14 def url @url end |
Instance Method Details
#do_request! ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/request.rb', line 26 def do_request! uri = URI.parse(@url) if @method == :post Net::HTTP.post_form uri, @params else #@browser.get(:url => @url, :headers => {'Authorization' => 'Basic ZGV2X3RlYW06RW5lcmd5Mi4w'}) @browser.get(@url) #http = Net::HTTP.new("testing.et-model.com") #@req = req = Net::HTTP::Get.new( #Net::HTTP.get_print uri #req = Net::HTTP::Get.new(uri) #req.basic_auth "dev_team", "Energy2.0" #response = http.request(req) #puts response.body end end |