quickpep 0.1.2 → 0.1.3

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
  SHA256:
3
- metadata.gz: 3d221c7f20a31b411a07147262470f088abb5f80805a04cbda3f03c07680b2f9
4
- data.tar.gz: cf6608382d9ff856726a0975665cc7164c527338785a557d6534b60e5e7356d0
3
+ metadata.gz: 00b7cb104e2090fb59936478625cf3802e3cb994b22279e1ee22b973749daed1
4
+ data.tar.gz: 051e2bc9b41b8fa555a47f0af0f2a069ce472ab65a60426d7a3c7dd8f0fee88f
5
5
  SHA512:
6
- metadata.gz: 046bbc33232ec683591919720f587bac94c429fceaadf02a8ddc1f871489cabcc006a6577fa17d0c1f562489f6a4eac304a26dc2d15f88124f01cf5d87292558
7
- data.tar.gz: c24f96ace7b00886716e5e1d2a928331738aef23d8f2a467dddb65d6941dbd4a5d4959aa13febae7cdc52743c59669711c8820bb9929e3493429765c892a664d
6
+ metadata.gz: 64e8b74f36ec2486e985e9c936735d7e6394315c479b829b95de2b426abb2d477be0497e6a37241c95993d487bafbe144f796084e9de8cd9fcacf9c4fa775dc2
7
+ data.tar.gz: d17d3b85c28bc7cfc7c633927122d28ef1d5644d7d9a48f440700fb19228a656fcab5f6c2a1ae09601a56262e2fddcc58df7d7b5e1c2d6fe4ac484b283dbe16b
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/quickpep.rb CHANGED
@@ -13,9 +13,10 @@ class QuickPep
13
13
 
14
14
  attr_reader :to_s
15
15
 
16
- def initialize(s, balance: 0, currency: '', debug: false)
16
+ def initialize(s, balance: 0, currency: '', today: Date.today, debug: false)
17
17
 
18
18
  @balance, @currency, @debug = balance, currency, debug
19
+ @today = today
19
20
  @warnings = []
20
21
  @to_s = calc_expenses(s)
21
22
 
@@ -23,9 +24,11 @@ class QuickPep
23
24
 
24
25
  end
25
26
 
26
- def annual_costs()
27
+ # options: year, month, weel, day
28
+ #
29
+ def annual_costs(perx=:year, per: perx)
27
30
 
28
- a = @date_events.map do |date, title|
31
+ rows = @date_events.map do |date, title|
29
32
 
30
33
  amount = @h[title].amount
31
34
 
@@ -36,9 +39,25 @@ class QuickPep
36
39
 
37
40
  end
38
41
 
39
- a.group_by {|date,title, amount| title }\
42
+ a = rows.group_by {|date,title, amount| title }\
40
43
  .map {|key, rows| [key, rows.map(&:last).sum]}.sort_by(&:last)
41
44
 
45
+ a.map do |title, total|
46
+
47
+ amount = case per.to_sym
48
+ when :year
49
+ total
50
+ when :month
51
+ total / (12 - @today.month)
52
+ when :week
53
+ total / (52 - @today.cweek )
54
+ when :day
55
+ total / (365 - @today.yday)
56
+ end
57
+
58
+ [title, amount.round(2)]
59
+ end
60
+
42
61
  end
43
62
 
44
63
  def warnings()
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quickpep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file