Sha256: 2a60b83089f773f0a7ab03c5305ee441e0187e5e790579b22887568d8d47cd10

Contents?: true

Size: 714 Bytes

Versions: 1

Compression:

Stored size: 714 Bytes

Contents

require "depreciate/version"
module Depreciate
  class Depreciate
    attr_accessor :unit, :cost, :acquisition_date, :lifetime, :residual_value
    def initialize(acquisition_date, cost, residual_value, lifetime, unit)
      @acquisition_date = acquisition_date
      @cost = cost.to_f
      @residual_value = residual_value
      @lifetime = lifetime
      @unit = unit
    end

    def value_lost_per_second
       return (@cost - @residual_value) / @lifetime
    end

    def straight_line_depreciation(evaluation_date = Time.now)
      value = cost - (evaluation_date - acquisition_date) * value_lost_per_second
      if value < @residual_value
        @residual_value
      end
      value
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
depreciate-0.1.1 lib/depreciate.rb