Class: IspUsage::Fetchers::AUIinet
- Defined in:
- lib/ispusage/fetchers/iinet.rb
Instance Attribute Summary collapse
-
#quota ⇒ Object
readonly
Returns the value of attribute quota.
-
#used ⇒ Object
readonly
Returns the value of attribute used.
Attributes inherited from Fetcher
#options, #password, #usage_periods, #username
Instance Method Summary collapse
- #fetch_usage ⇒ Object
-
#initialize(options) ⇒ AUIinet
constructor
A new instance of AUIinet.
Methods inherited from Fetcher
Constructor Details
#initialize(options) ⇒ AUIinet
Returns a new instance of AUIinet.
9 10 11 |
# File 'lib/ispusage/fetchers/iinet.rb', line 9 def initialize() super() end |
Instance Attribute Details
#quota ⇒ Object (readonly)
Returns the value of attribute quota.
8 9 10 |
# File 'lib/ispusage/fetchers/iinet.rb', line 8 def quota @quota end |
#used ⇒ Object (readonly)
Returns the value of attribute used.
8 9 10 |
# File 'lib/ispusage/fetchers/iinet.rb', line 8 def used @used end |
Instance Method Details
#fetch_usage ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/ispusage/fetchers/iinet.rb', line 13 def fetch_usage xml = open("https://toolbox.iinet.net.au/cgi-bin/new/volume_usage_xml.cgi?action=login&username=#{@username}&password=#{@password}") doc = Nokogiri::XML(xml) used = doc.search("/ii_feed[1]/volume_usage[1]/expected_traffic_types[1]/type[1]/@used").text.to_i / 998315 #best I can figure iinet uses base 2 and base 10 bytes quota = doc.search("/ii_feed[1]/volume_usage[1]/expected_traffic_types[1]/type[1]/quota_allocation[1]").text.to_i self.usage_periods << UsagePeriod.new(:used => used, :quota => quota) end |