Class: Strawman::Proxy
- Inherits:
-
Object
- Object
- Strawman::Proxy
- Defined in:
- lib/strawman/proxy.rb
Overview
The general proxy class, which contains functions not specific to any type of proxy.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#root_url ⇒ Object
readonly
Returns the value of attribute root_url.
-
#valid ⇒ Object
writeonly
Sets the attribute valid.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(url) ⇒ Proxy
constructor
A new instance of Proxy.
-
#proxy_url(url) ⇒ Object
Returns the url to fetch the given url through this proxy.
-
#referer ⇒ Object
Returns the the referer to use when making the proxied request.
-
#valid? ⇒ Boolean
Used to determine whether this proxy is valid.
-
#validate_response ⇒ Object
Returns the response of the validate request from the proxy.
Constructor Details
#initialize(url) ⇒ Proxy
Returns a new instance of Proxy.
10 11 12 13 14 |
# File 'lib/strawman/proxy.rb', line 10 def initialize(url) @root_url = url @valid = false @validate_response = "" end |
Instance Attribute Details
#root_url ⇒ Object (readonly)
Returns the value of attribute root_url.
7 8 9 |
# File 'lib/strawman/proxy.rb', line 7 def root_url @root_url end |
#valid=(value) ⇒ Object (writeonly)
Sets the attribute valid
8 9 10 |
# File 'lib/strawman/proxy.rb', line 8 def valid=(value) @valid = value end |
Instance Method Details
#==(other) ⇒ Object
46 47 48 |
# File 'lib/strawman/proxy.rb', line 46 def ==(other) self.class == other.class && self.root_url == other.root_url end |
#proxy_url(url) ⇒ Object
Returns the url to fetch the given url through this proxy.
26 27 28 29 |
# File 'lib/strawman/proxy.rb', line 26 def proxy_url(url) uri = URI.join @root_url, proxy_path(url) "#{uri.scheme}://#{uri.host}:#{uri.port}#{uri.path}?#{uri.query}" end |
#referer ⇒ Object
Returns the the referer to use when making the proxied request.
19 20 21 |
# File 'lib/strawman/proxy.rb', line 19 def referer @root_url end |
#valid? ⇒ Boolean
Used to determine whether this proxy is valid. This must be called from within the callback of the validate deferable.
35 36 37 |
# File 'lib/strawman/proxy.rb', line 35 def valid? @valid end |
#validate_response ⇒ Object
Returns the response of the validate request from the proxy.
42 43 44 |
# File 'lib/strawman/proxy.rb', line 42 def validate_response @validate_response end |