lib/capwatch/fund.rb in capwatch-0.2.3 vs lib/capwatch/fund.rb in capwatch-0.2.4
- old
+ new
@@ -39,16 +39,30 @@
def percent_change_7d
coins.map { |coin| coin.percent_change_7d * coin.distribution }.sum
end
def build
- calculator.assign_quantity
- calculator.assign_prices
- calculator.distribution
+ assign_quantity
+ assign_prices
+ distribution
end
- def calculator
- @calculator ||= FundCalculator.new(self)
+ def assign_quantity
+ coins.each do |coin|
+ coin.quantity = positions[coin.symbol]
+ end
+ end
+
+ def assign_prices
+ coins.each do |coin|
+ provider.update_coin(coin)
+ end
+ end
+
+ def distribution
+ coins.each do |coin|
+ coin.distribution = coin.value_btc / value_btc
+ end
end
def serialize
coins.map { |coin| coin.serialize }.to_json
end