Class: Typhoeus::Request

Inherits:
Object show all
Defined in:
lib/typhoeus/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ Request

Returns a new instance of Request.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/typhoeus/request.rb', line 27

def initialize( url, options = {} )

    old_initialize( url, options )

    @proxy_type       = options[:proxy_type]
    @proxy_username   = options[:proxy_username]
    @proxy_password   = options[:proxy_password]
    @proxy_auth_method = options[:proxy_auth_method]

    @on_complete        = []
    @handled_response   = []
    @multiple_callbacks = false
    @train              = false
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



22
23
24
# File 'lib/typhoeus/request.rb', line 22

def id
  @id
end

#proxyObject

Returns the value of attribute proxy.



22
23
24
# File 'lib/typhoeus/request.rb', line 22

def proxy
  @proxy
end

#proxy_passwordObject

Returns the value of attribute proxy_password.



22
23
24
# File 'lib/typhoeus/request.rb', line 22

def proxy_password
  @proxy_password
end

#proxy_typeObject

Returns the value of attribute proxy_type.



22
23
24
# File 'lib/typhoeus/request.rb', line 22

def proxy_type
  @proxy_type
end

#proxy_usernameObject

Returns the value of attribute proxy_username.



22
23
24
# File 'lib/typhoeus/request.rb', line 22

def proxy_username
  @proxy_username
end

Instance Method Details

#call_handlersObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/typhoeus/request.rb', line 66

def call_handlers

    if @on_complete.is_a? Array

        @on_complete.each do |callback|
            @handled_response << callback.call(response)
        end

    else
        @handled_response << @on_complete.call(response)
    end

  call_after_complete
end

#old_initializeObject



25
# File 'lib/typhoeus/request.rb', line 25

alias :old_initialize :initialize

#on_complete(multi = false, &block) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/typhoeus/request.rb', line 42

def on_complete( multi = false, &block )

    # remember user preference for subsequent calls
    if( multi || @multiple_callbacks )
        @multiple_callbacks = true
        @on_complete << block
    else
        @on_complete = block
    end

end

#on_complete=(multi = false, proc) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/typhoeus/request.rb', line 54

def on_complete=( multi = false, proc )

    # remember user preference for subsequent calls
    if( multi || @multiple_callbacks )
        @multiple_callbacks = true
        @on_complete << proc
    else
        @on_complete = proc
    end

end

#train!Object



85
86
87
# File 'lib/typhoeus/request.rb', line 85

def train!
    @train = true
end

#train?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/typhoeus/request.rb', line 81

def train?
    @train
end