Class: ItasaAgent

Inherits:
Object
  • Object
show all
Defined in:
lib/subdl/italiansubs.rb

Instance Method Summary collapse

Constructor Details

#initializeItasaAgent

Returns a new instance of ItasaAgent.



5
6
7
8
9
# File 'lib/subdl/italiansubs.rb', line 5

def initialize
  @agent = Mechanize.new do |a|
    a.user_agent_alias = 'Mac FireFox'
  end
end

Instance Method Details

#get(url) ⇒ Object



11
12
13
# File 'lib/subdl/italiansubs.rb', line 11

def get url
  @agent.get url
end

#login(username, password) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/subdl/italiansubs.rb', line 15

def  username, password
  return if logged_in?
   = 'http://www.italiansubs.net'
  home_page = @agent.get 
   = home_page.form 'login'
  .username = username
  .passwd = password
  @page = @agent.submit()
end