Class: PhantomJSProxy::PhantomJSControlPanel

Inherits:
Object
  • Object
show all
Defined in:
lib/phantom_proxy/phantomjs_control_panel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePhantomJSControlPanel

Returns a new instance of PhantomJSControlPanel.



3
4
5
6
7
8
# File 'lib/phantom_proxy/phantomjs_control_panel.rb', line 3

def initialize
  @start_time = Time.new
  @total_requests = 0
  @special_requests = Hash.new
  @special_requests.default = 0
end

Instance Attribute Details

#html_requestsObject

Returns the value of attribute html_requests.



14
15
16
# File 'lib/phantom_proxy/phantomjs_control_panel.rb', line 14

def html_requests
  @html_requests
end

#picture_requestsObject

Returns the value of attribute picture_requests.



15
16
17
# File 'lib/phantom_proxy/phantomjs_control_panel.rb', line 15

def picture_requests
  @picture_requests
end

#route_requestsObject

Returns the value of attribute route_requests.



13
14
15
# File 'lib/phantom_proxy/phantomjs_control_panel.rb', line 13

def route_requests
  @route_requests
end

#special_requestsObject

Returns the value of attribute special_requests.



16
17
18
# File 'lib/phantom_proxy/phantomjs_control_panel.rb', line 16

def special_requests
  @special_requests
end

#start_timeObject

Returns the value of attribute start_time.



10
11
12
# File 'lib/phantom_proxy/phantomjs_control_panel.rb', line 10

def start_time
  @start_time
end

#total_requestsObject

Returns the value of attribute total_requests.



12
13
14
# File 'lib/phantom_proxy/phantomjs_control_panel.rb', line 12

def total_requests
  @total_requests
end

Instance Method Details

#add_requestObject



29
30
31
# File 'lib/phantom_proxy/phantomjs_control_panel.rb', line 29

def add_request
  @total_requests = @total_requests+1
end

#add_special_request(type) ⇒ Object



33
34
35
# File 'lib/phantom_proxy/phantomjs_control_panel.rb', line 33

def add_special_request type
  @special_requests[type] = @special_requests[type]+1
end

#showObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/phantom_proxy/phantomjs_control_panel.rb', line 18

def show
  add_special_request "@control_requests"
  
  resp = Rack::Response.new([], 200,   {
    'Content-Type' => 'text/html'
    }) { |r|
      r.write(load_html)
    }
  resp.finish
end