roi_calculator 0.3.1 → 0.3.6

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: b06447f127f9d752c3ae78fe7c181fe6e7c7e52a2e8c71b4831c5e004970f4c3
4
- data.tar.gz: 38a1e88a62e8dfb06ff9a8512351fac45a5c8b5dd4ed7b19d8655effbfdcdf25
3
+ metadata.gz: d374c0e5a2f5bc8659091bcdb627b31f9da5bada6bc92de1d3334c532eb704dd
4
+ data.tar.gz: d938f830840cbb8cb8de02ac6ebbb092968cf4c912e6b2575aecfe1847ed20e9
5
5
  SHA512:
6
- metadata.gz: 89355e8984aefe5b2efb46f795fc89e8fa0024279bcc662b4d59c22183beb533d7ace66c23d059e207011c4b5c955bab2616b561c063ae1c9f8d4d4bea16fa4c
7
- data.tar.gz: 1cd31cbc980fd8f0920af5a90665b23ffcee2ca9f4a3c4473138c14ca99b70962fc674093f9c7ae50a69ac0e7a59e56a554387f8a1e74e028372e7c186cbb126
6
+ metadata.gz: 1be3092e3cb334a65cd96f3763daf591e2c4b57c115ccdded5d4b142849f1bb96c34b420f1f1e78df9a4e8f240bcb73d4f6ddf9a7e7e74dce88de5583e246d49
7
+ data.tar.gz: 2f00910f9eb75e1a6a65058aef5b0c4b87a9b82a89a80c59fdc584f180d3a666ea15c62366a1639f857d9aae8ad85d6c8eb752535d32752161b059a1d2b6a0a1
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+ gem 'pry'
@@ -71,7 +71,7 @@ module ROI
71
71
  def to_a
72
72
  dates_with_position.map do |date|
73
73
  if @rentabilities[date]
74
- [date.to_time.to_i, @rentabilities[date].share]
74
+ [date.strftime('%Y-%m-%d'), @rentabilities[date].share - 1]
75
75
  end
76
76
  end.compact
77
77
  end
@@ -12,11 +12,22 @@ module ROI
12
12
  check_gaps_and_format(adjust_start_date(scoped_start), end_date)
13
13
  end
14
14
 
15
- def months(amount, date = end_date)
15
+ def month(date = end_date)
16
+ return current_month if date == end_date
17
+
18
+ scoped_start = WorkDay.last_until((date - 1.month).end_of_month)
19
+ scoped_end = adjust_end_date(date)
20
+ check_gaps_and_format(scoped_start, scoped_end)
21
+ end
22
+
23
+ def months_ago(amount, date = end_date)
24
+ return current_month if amount == 1 && date == end_date
25
+
16
26
  scoped_start = WorkDay.last_until((date - (amount+1).month).end_of_month)
17
27
  scoped_end = adjust_end_date((date - 1.month).end_of_month)
18
28
  check_gaps_and_format(scoped_start, scoped_end)
19
29
  end
30
+ alias_method :months, :months_ago
20
31
 
21
32
  def current_year
22
33
  scoped_start = WorkDay.last_until((end_date - 1.year).end_of_year)
@@ -1,3 +1,3 @@
1
1
  module ROI
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roi_calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adriano Bacha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-23 00:00:00.000000000 Z
11
+ date: 2021-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler