Class: IspUsage::Fetchers::AUTranslink
- Defined in:
- lib/ispusage/fetchers/au_translink.rb
Instance Attribute Summary
Attributes inherited from Fetcher
#error, #month_end, #options, #password, #usage_periods, #username
Instance Method Summary collapse
- #fetch_usage ⇒ Object
-
#initialize(options) ⇒ AUTranslink
constructor
A new instance of AUTranslink.
Methods inherited from Fetcher
#month_used, #new_usage_period, #to_hash, #to_json
Constructor Details
#initialize(options) ⇒ AUTranslink
Returns a new instance of AUTranslink.
7 8 9 |
# File 'lib/ispusage/fetchers/au_translink.rb', line 7 def initialize() super() end |
Instance Method Details
#fetch_usage ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ispusage/fetchers/au_translink.rb', line 11 def fetch_usage agent = Mechanize.new page = agent.get('https://www.seqits.com.au/webtix/') login_form = page.form('form2') login_form['cardNum'] = self.username login_form.pass = self.password page = agent.submit(login_form, login_form..first) usage = self.new_usage_period(:type => :balance) self.usage_periods << usage usage.used = page.search('.results_table/tr[2]/td[2]').text.match(/\d+\.\d+/)[0].to_f end |