Sha256: 488c6e132392f99549fa25d9bf7c133451257acd10e5957c183016d97155b112
Contents?: true
Size: 1014 Bytes
Versions: 2
Compression:
Stored size: 1014 Bytes
Contents
require 'csv' require 'colorize' class Rebate_calculator def initialize(postcode, kw, deeming_year) @postcode = postcode @kw = kw @deeming_year = deeming_year @stc_rating = 0 @stc = 0 end def stc_postcode_rating csv_text = File.read(__dir__ + '/stc_rating.csv') csv = CSV.parse(csv_text, headers: true) result = csv.find do |num| stc_table = num.to_hash @postcode >= stc_table['Postcode from'].to_i && @postcode <= stc_table['Postcode to'].to_i end @stc_rating = result['Rating'].to_f stc_calculator end private def stc_calculator @stc = (@kw * @stc_rating * @deeming_year).floor rebate end def rebate stc_value = 37.5 rebate_amount = @stc * stc_value if rebate_amount > 1888 puts "Total amount of your solar panel rebate has reach the maximum, which is $1888 aud.".colorize(:red) else puts "Total amount of your solar panel rebate is $#{rebate_amount} aud".colorize(:red) end rebate_amount end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jishan_fast_track_gem-0.1.13 | lib/rebate_calculator.rb |
jishan_fast_track_gem-0.1.12 | lib/rebate_calculator.rb |