Class: DBCOverflow

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/dbcoverflow.rb

Instance Method Summary collapse

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.options[: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)
  options = {:query => {:title => title, :content => content} }
  options.merge!({:headers => {"Cookie" => @cookie, 'Content-Type' => 'application/x-www-form-urlencoded'}})
  self.class.post('/questions', options)
end