Class: ItasaAgent
- Inherits:
-
Object
- Object
- ItasaAgent
- Defined in:
- lib/subdl/italiansubs.rb
Instance Method Summary collapse
- #get(url) ⇒ Object
-
#initialize ⇒ ItasaAgent
constructor
A new instance of ItasaAgent.
- #login(username, password) ⇒ Object
Constructor Details
#initialize ⇒ ItasaAgent
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 login username, password return if logged_in? page_where_to_login = 'http://www.italiansubs.net' home_page = @agent.get page_where_to_login login_form = home_page.form 'login' login_form.username = username login_form.passwd = password @page = @agent.submit(login_form) end |