Class: VBulletin::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/vbulletin/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(url, options = {}) ⇒ Base
Returns a new instance of Base.
6
7
8
9
10
|
# File 'lib/vbulletin/base.rb', line 6
def initialize(url, options = {})
@uri = URI::parse(url)
@debug = options[:debug] || false
@api = self
end
|
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
4
5
6
|
# File 'lib/vbulletin/base.rb', line 4
def debug
@debug
end
|
#mechanize ⇒ Object
Returns the value of attribute mechanize.
4
5
6
|
# File 'lib/vbulletin/base.rb', line 4
def mechanize
@mechanize
end
|
#uri ⇒ Object
Returns the value of attribute uri.
4
5
6
|
# File 'lib/vbulletin/base.rb', line 4
def uri
@uri
end
|
Instance Method Details
#construct_full_url(path, params = nil) ⇒ Object
48
49
50
|
# File 'lib/vbulletin/base.rb', line 48
def construct_full_url(path, params = nil)
"#{self.uri.scheme}://#{self.uri.host}#{construct_url(path, params)}"
end
|
#construct_url(path, params = nil) ⇒ Object
44
45
46
|
# File 'lib/vbulletin/base.rb', line 44
def construct_url(path, params = nil)
"#{self.uri.path}/#{path}#{VBulletin::Base.hash2get(params)}"
end
|
#forums ⇒ Object
34
35
36
|
# File 'lib/vbulletin/base.rb', line 34
def forums
VBulletin::Forum.new(self)
end
|
#get_index ⇒ Object
29
30
31
32
|
# File 'lib/vbulletin/base.rb', line 29
def get_index
index = self.mechanize.get(construct_full_url('index.php'))
puts index.body
end
|
#login(username, password) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/vbulletin/base.rb', line 12
def login(username, password)
mechanize = Mechanize.new
mechanize.get(construct_full_url('login.php', { 'do' => 'login' })) do |login_page|
login_page.form_with(:action => 'login.php?do=login') do |f|
f.vb_login_username = username
f.vb_login_md5password = password
end.click_button
end
self.mechanize = mechanize
end
|
#search ⇒ Object
38
39
40
|
# File 'lib/vbulletin/base.rb', line 38
def search
VBulletin::Search.new(self)
end
|