Class: UnderOs::HTTP::Request
- Includes:
- Events
- Defined in:
- lib/under_os/http/request.rb,
lib/under_os/http/receiver.rb
Overview
A little wrap to handle iOS HTTP requests receiving
Defined Under Namespace
Classes: Receiver
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #cancel ⇒ Object
- #cookies ⇒ Object
- #encoding ⇒ Object
- #headers ⇒ Object
-
#initialize(url, options = {}, &block) ⇒ Request
constructor
A new instance of Request.
- #on(*args, &block) ⇒ Object
- #send ⇒ Object
Methods included from Events
Constructor Details
#initialize(url, options = {}, &block) ⇒ Request
Returns a new instance of Request.
23 24 25 26 27 28 |
# File 'lib/under_os/http/request.rb', line 23 def initialize(url, ={}, &block) @url = url @options = on :complete, &block if block_given? end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
21 22 23 |
# File 'lib/under_os/http/request.rb', line 21 def method @method end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
21 22 23 |
# File 'lib/under_os/http/request.rb', line 21 def params @params end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
21 22 23 |
# File 'lib/under_os/http/request.rb', line 21 def url @url end |
Instance Method Details
#cancel ⇒ Object
46 47 48 49 50 |
# File 'lib/under_os/http/request.rb', line 46 def cancel @connection.cancel return self end |
#cookies ⇒ Object
63 64 65 |
# File 'lib/under_os/http/request.rb', line 63 def @options[:cookies] || {} end |
#encoding ⇒ Object
71 72 73 |
# File 'lib/under_os/http/request.rb', line 71 def encoding @options[:encoding] || 'utf-8' end |
#headers ⇒ Object
59 60 61 |
# File 'lib/under_os/http/request.rb', line 59 def headers @options[:headers] || {} end |
#on(*args, &block) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/under_os/http/request.rb', line 30 def on(*args, &block) super *args do |event| args = block.arity == 0 ? [] : [event.params[:response]] block.call *args end end |