class SpsBill::Bill

SpsBill::Bill represents an individual SP Services PDF bill

It is initialised given a file name, and provides a range of accessors to get at individual data elements (e.g. electricity_usage)

Attributes

account_number[R]

accessors for the various bill components

electricity_usage[R]

electricity_usage is an array of hashed values:

[{ kwh: float, rate: float, amount: float }]
gas_usage[R]

gas_usage is an array of hashed values:

[{ kwh: float, rate: float, amount: float }]
invoice_date[R]

accessors for the various bill components

invoice_month[R]

accessors for the various bill components

source_file[R]
total_amount[R]

accessors for the various bill components

water_usage[R]

water_usage is an array of hashed values:

[{ cubic_m: float, rate: float, amount: float }]

Public Class Methods

new(source) click to toggle source

source is a file name or stream-like object

# File lib/sps_bill/bill.rb, line 27
def initialize(source)
  @source_file = source
  do_complete_parse
end

Public Instance Methods

reader() click to toggle source

Returns the PDF reader isntance

# File lib/sps_bill/bill.rb, line 33
def reader
  @reader ||= PDF::Reader::Turtletext.new(source_file) if source_file
end
to_s() click to toggle source

Return a pretty(-ish) text format of the core bill details

# File lib/sps_bill/bill.rb, line 38
  def to_s
    %(
Account number: #{account_number}
Invoice date  : #{invoice_date}
Service month : #{invoice_month}
Total bill    : $#{total_amount}

Electricity Usage
-----------------
#{electricity_usage}

Gas Usage
---------
#{gas_usage}

Water Usage
-----------
#{water_usage}

      )
  end