Class: Dolla::PaymentSlip::Amount

Inherits:
Object
  • Object
show all
Defined in:
lib/dolla/payment_slip/amount.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number) ⇒ Amount

Returns a new instance of Amount.



8
9
10
# File 'lib/dolla/payment_slip/amount.rb', line 8

def initialize number
  @value = format_amount number
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/dolla/payment_slip/amount.rb', line 4

def value
  @value
end

Instance Method Details

#hashObject



12
13
14
15
16
17
# 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