lib/adsense-info.rb in adsense-info-1.0.3 vs lib/adsense-info.rb in adsense-info-1.0.4
- old
+ new
@@ -19,12 +19,36 @@
@agent.submit form
end
nil
end
- def today_so_far
+ def update_values!
login!
- ( get('https://www.google.com/adsense/v3/m/home') / 'span[@class~=value]' ).first.inner_html
+ 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
+
+ def today_so_far
+ update_values! unless @today_so_far
+ @today_so_far
+ end
+
+ def yesterday
+ update_values! unless @yesterday
+ @yesterday
+ end
+
+ def this_month_so_far
+ update_values! unless @this_month_so_far
+ @this_month_so_far
+ end
+
+ def last_month
+ update_values! unless @last_month
+ @last_month
end
private
def get( url )