Class: Adsense::Info
- Inherits:
-
Object
- Object
- Adsense::Info
- Defined in:
- lib/adsense-info.rb,
lib/adsense-info/version.rb
Constant Summary collapse
- VERSION =
"1.0.4"
Instance Method Summary collapse
-
#initialize(username, password) ⇒ Info
constructor
A new instance of Info.
- #last_month ⇒ Object
- #login! ⇒ Object
- #this_month_so_far ⇒ Object
- #today_so_far ⇒ Object
- #update_values! ⇒ Object
- #yesterday ⇒ Object
Constructor Details
#initialize(username, password) ⇒ Info
Returns a new instance of Info.
7 8 9 10 11 |
# File 'lib/adsense-info.rb', line 7 def initialize( username, password ) @username = username @password = password @agent = Mechanize::Mechanize.new end |
Instance Method Details
#last_month ⇒ Object
48 49 50 51 |
# File 'lib/adsense-info.rb', line 48 def last_month update_values! unless @last_month @last_month end |
#login! ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/adsense-info.rb', line 13 def login! page = @agent.get 'http://www.gmail.com' form = page.forms.first if form form.Email = @username form.Passwd = @password @agent.submit form end nil end |
#this_month_so_far ⇒ Object
43 44 45 46 |
# File 'lib/adsense-info.rb', line 43 def this_month_so_far update_values! unless @this_month_so_far @this_month_so_far end |
#today_so_far ⇒ Object
33 34 35 36 |
# File 'lib/adsense-info.rb', line 33 def today_so_far update_values! unless @today_so_far @today_so_far end |
#update_values! ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/adsense-info.rb', line 24 def update_values! login! values = ( get('https://www.google.com/adsense/v3/m/home') / 'span[@class~=value]' ) @today_so_far = values[0].inner_html @yesterday = values[1].inner_html @this_month_so_far = values[2].inner_html @last_month = values[3].inner_html end |
#yesterday ⇒ Object
38 39 40 41 |
# File 'lib/adsense-info.rb', line 38 def yesterday update_values! unless @yesterday @yesterday end |