Class: DBCOverflow
Instance Method Summary collapse
-
#initialize(u, p) ⇒ DBCOverflow
constructor
A new instance of DBCOverflow.
- #new_question(title, content) ⇒ Object
Constructor Details
#initialize(u, p) ⇒ DBCOverflow
Returns a new instance of DBCOverflow.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dbcoverflow.rb', line 8 def initialize(u, p) response = self.class.get('/') response = self.class.post( '/users', :body => { :username => u, :password => p }, :headers => {'Cookie' => response.headers['Set-Cookie']} ) @response = response @cookie = response.request.[:headers]['Cookie'] end |
Instance Method Details
#new_question(title, content) ⇒ Object
19 20 21 22 23 |
# File 'lib/dbcoverflow.rb', line 19 def new_question(title, content) = {:query => {:title => title, :content => content} } .merge!({:headers => {"Cookie" => @cookie, 'Content-Type' => 'application/x-www-form-urlencoded'}}) self.class.post('/questions', ) end |