Class: Reckon::MoneyColumn
- Inherits:
-
Array
- Object
- Array
- Reckon::MoneyColumn
- Defined in:
- lib/reckon/money.rb
Instance Method Summary collapse
-
#initialize(arr = [], options = {}) ⇒ MoneyColumn
constructor
A new instance of MoneyColumn.
- #merge!(other_column) ⇒ Object
- #positive? ⇒ Boolean
Constructor Details
#initialize(arr = [], options = {}) ⇒ MoneyColumn
Returns a new instance of MoneyColumn.
96 97 98 |
# File 'lib/reckon/money.rb', line 96 def initialize(arr = [], = {}) arr.each { |str| push(Money.new(str, )) } end |
Instance Method Details
#merge!(other_column) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/reckon/money.rb', line 107 def merge!(other_column) invert = false invert = true if positive? && other_column.positive? each_with_index do |mon, i| other = other_column[i] return nil if !mon || !other if mon != 0.0 && other == 0.0 self[i] = -mon if invert elsif mon == 0.0 && other != 0.0 self[i] = other else self[i] = Money.new(0) end end self end |
#positive? ⇒ Boolean
100 101 102 103 104 105 |
# File 'lib/reckon/money.rb', line 100 def positive? each do |money| return false if money && money < 0 end true end |