Sha256: 9960847392cd6ffd982f9af09a07bb31f3803a4ce2e3bc9ceb9584ff827e364a
Contents?: true
Size: 891 Bytes
Versions: 1
Compression:
Stored size: 891 Bytes
Contents
require 'csv' require 'colorize' class Rebate_calculator def initialize @stc_rating = 0 @stc = 0 end def stc_postcode_rating(postcode) 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 end def stc_calculator(kw, deeming_year) @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 maximun, which is $1888 aud.".colorize(:red) else puts "Total amount of your solar panel rebate is $#{rebate_amount} aud".colorize(:red) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jishan_fast_track_gem-0.1.10 | lib/rebate_calculator.rb |