mycoins 0.3.7 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6153c7afb14e558185a2af0c6b1ec3623f99f886
4
- data.tar.gz: 60e06ac72917aa033a87a41191c9f734b919799f
3
+ metadata.gz: 47dcc541e45f8989c7e2eeb0a4f0530e341ac53a
4
+ data.tar.gz: c02b4940babaccf08ca10eefe96aaa5abe17df50
5
5
  SHA512:
6
- metadata.gz: 9eea23b595d36c85741bef1287287a2da2c6140fffeb88fe365310b229630cbe6fa91ae90ec79cf94a2e61e1add58b134e8eaadaefd2f7ea6b5b06173d4ec6ef
7
- data.tar.gz: a63c559a27b3b1023b47f4d01091dacdf1d70561c7cd284725c9a8520a9ef68631ddfbf4adaf4ec56a664c502389538082495792af3b32e21701d6b842c671e0
6
+ metadata.gz: 5156b6728448f20d2304be6a202e4eac12d64832d60b06a8c3fd501d47d7789b0c376b05c4dda404c3a5cea880d23e18d8eec9cd4919eb6aa674b2b76e87266b
7
+ data.tar.gz: 057ce6e999d71f7230c719ec17b4457edac3d69dbd7fcca95fdc2acef666aaf5c4355fb20d25f8fcd66ef6cc33895e14ccfd25ed9c3c238a5de1f3fdae08a57e
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/mycoins.rb CHANGED
@@ -137,6 +137,20 @@ class MyCoins
137
137
 
138
138
  end
139
139
 
140
+ # returns a Hash object containing the value as well as the percentage relative to the
141
+ # total value of the portfolio for each cryptocurrency
142
+ #
143
+ def to_values()
144
+
145
+ portfolio = build_portfolio()
146
+
147
+ self.to_percentages.inject({}) do |r, x|
148
+ currency, pct = x
149
+ r.merge!(currency => [pct, ((portfolio.value * pct) / 100).round(2)])
150
+ end
151
+
152
+ end
153
+
140
154
  def to_xml()
141
155
 
142
156
  self.to_dx().to_xml pretty: true
@@ -145,7 +159,7 @@ class MyCoins
145
159
 
146
160
  private
147
161
 
148
- def build_portfolio(title)
162
+ def build_portfolio(title='CryptoCurrency Portfolio ' + Time.now.year.to_s)
149
163
 
150
164
  if @portfolio and \
151
165
  DateTime.parse(@portfolio.datetime) + 60 > DateTime.now then
@@ -207,7 +221,12 @@ class MyCoins
207
221
  end
208
222
 
209
223
  coin = @ccf.find(title)
210
- raise 'build_records error: coin nil' if coin.nil?
224
+
225
+ if coin.nil? then
226
+ puts 'warning: build_records error: coin nil for title ' \
227
+ + title.inspect
228
+ return r
229
+ end
211
230
 
212
231
  puts 'coin: ' + coin.inspect if @debug
213
232
  usd_rate = coin.price_usd.to_f
@@ -261,6 +280,7 @@ class MyCoins
261
280
 
262
281
  h = coin_names.inject({}) do |r, name|
263
282
 
283
+ puts 'name: ' + name.inspect if @debug
264
284
  found = c.find name
265
285
  r.merge(name => found.symbol)
266
286
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mycoins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -30,7 +30,7 @@ cert_chain:
30
30
  sCz5KsiHA9vj8OfrxhYrEb+ML4+J28Umdki7V1vgnQWmnI+Ok2SWlkScgzcmGXF6
31
31
  TJ4=
32
32
  -----END CERTIFICATE-----
33
- date: 2018-05-02 00:00:00.000000000 Z
33
+ date: 2018-05-13 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: dynarex
metadata.gz.sig CHANGED
Binary file