Class: GoogleText::Session
- Inherits:
-
Object
- Object
- GoogleText::Session
- Defined in:
- lib/google_text/session.rb
Instance Method Summary collapse
- #body ⇒ Object
- #get(url) ⇒ Object
-
#initialize ⇒ Session
constructor
A new instance of Session.
- #post(url, fields = []) ⇒ Object
- #response_code ⇒ Object
- #url ⇒ Object
- #url=(url) ⇒ Object
Constructor Details
#initialize ⇒ Session
Returns a new instance of Session.
3 4 5 6 7 8 9 |
# File 'lib/google_text/session.rb', line 3 def initialize @proxy = Curl::Easy.new do |curl| curl.headers["User-Agent"] = GoogleText.configuration.user_agent curl.follow_location = true curl. = true end end |
Instance Method Details
#body ⇒ Object
11 12 13 14 |
# File 'lib/google_text/session.rb', line 11 def body body = @proxy.body_str body.respond_to?(:force_encoding) ? body.force_encoding('utf-8') : body end |
#get(url) ⇒ Object
16 17 18 19 20 |
# File 'lib/google_text/session.rb', line 16 def get(url) self.url = url @proxy.perform handle_response end |
#post(url, fields = []) ⇒ Object
22 23 24 25 26 |
# File 'lib/google_text/session.rb', line 22 def post(url,fields=[]) self.url = url @proxy.http_post fields handle_response end |
#response_code ⇒ Object
36 37 38 |
# File 'lib/google_text/session.rb', line 36 def response_code @proxy.response_code end |
#url ⇒ Object
28 29 30 |
# File 'lib/google_text/session.rb', line 28 def url @proxy.url end |
#url=(url) ⇒ Object
32 33 34 |
# File 'lib/google_text/session.rb', line 32 def url=(url) @proxy.url = url end |