Class: IspUsage::Fetchers::AUTranslink

Inherits:
Fetcher
  • Object
show all
Defined in:
lib/ispusage/fetchers/au_translink.rb

Instance Attribute Summary

Attributes inherited from Fetcher

#options, #password, #usage_periods, #username

Instance Method Summary collapse

Methods inherited from Fetcher

#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(options)
  super(options)
end

Instance Method Details

#fetch_usageObject



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/')
   = page.form('form2')
  ['cardNum'] = self.username
  .pass = self.password
  page = agent.submit(, .buttons.first)

  usage = UsagePeriod.new(:type => :balance)
  self.usage_periods << usage

  usage.used = page.search('.results_table/tr[2]/td[2]').text.match(/\d+\.\d+/)[0].to_f
end