class Dolla::PaymentSlip::Amount

Attributes

value[R]

Public Class Methods

new(number) click to toggle source
# File lib/dolla/payment_slip/amount.rb, line 8
def initialize number
  @value = format_amount number
end

Public Instance Methods

hash() click to toggle source
# File lib/dolla/payment_slip/amount.rb, line 12
def hash
  filler_string = "".ljust( length, "731" ).reverse
  (0..length-1).inject(0) do |sum, position|
    sum + value[ position, 1 ].to_i * filler_string[ position, 1 ].to_i
  end % 10
end

Private Instance Methods

format_amount(number) click to toggle source
# File lib/dolla/payment_slip/amount.rb, line 21
def format_amount number
  "%d" % ( number * 100 ).round
end