roi_calculator 0.3.2 → 0.3.7

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
- SHA256:
3
- metadata.gz: 2928abf9c33dd3a784c8e27343271293d13422d78ab2e2f154b74c4b5e65b408
4
- data.tar.gz: 5095434c72d10e868a39611cf6f87e9000d06a568b242ee05f5b6c9b1211ae27
2
+ SHA1:
3
+ metadata.gz: 8abe9ea75aac2649c2a444298c24e21c2bfa96d9
4
+ data.tar.gz: 69d88fdd5969f937e7ff45aee9cf99e04edb3f5d
5
5
  SHA512:
6
- metadata.gz: a05ffaf084494ed374380bd456f7697924fd660ac28030807f1080dca451ad52eb69b2933ced69b2adb09bafe81557e2d1e3f67fa6838bc00e734505c5e152b5
7
- data.tar.gz: d6c47125bebbd9bb8ea01e1fe7f97b6d403ad973679693d79db125ad250b3a8580ce599b06ec8355ba89ca5f60f68df26995319c92d9662288a37022190d3f92
6
+ metadata.gz: f5dc672a2996187b537a72e861bb0bd005c1415ecfb2b781b6331c8bab67c66d136c36eb716777f373d06d92b5e69e368c7f40d2d239fc3fda9aa54e3e5194e3
7
+ data.tar.gz: ee98cf1a647a80f80b78cac0c024ef0ed42f24a73de44ad8587cca6f0bab9f9c26af14e2771bca1660453c2efd94e688cc39408bd2b881dfeaf059e16bca2a87
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.strftime('%Y-%m-%d'), @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,25 @@ 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)
16
- scoped_start = WorkDay.last_until((date - (amount+1).month).end_of_month)
17
- scoped_end = adjust_end_date((date - 1.month).end_of_month)
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
+
26
+ end_of_month = WorkDay.last_until(date.end_of_month)
27
+ offset = date == end_of_month ? 0 : 1
28
+
29
+ scoped_start = WorkDay.last_until((date - (amount + offset).month).end_of_month)
30
+ scoped_end = adjust_end_date((date - offset.month).end_of_month)
18
31
  check_gaps_and_format(scoped_start, scoped_end)
19
32
  end
33
+ alias_method :months, :months_ago
20
34
 
21
35
  def current_year
22
36
  scoped_start = WorkDay.last_until((end_date - 1.year).end_of_year)
data/lib/roi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ROI
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.7"
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.2
4
+ version: 0.3.7
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-29 00:00:00.000000000 Z
11
+ date: 2021-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -123,7 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 3.0.8
126
+ rubyforge_project:
127
+ rubygems_version: 2.4.8
127
128
  signing_key:
128
129
  specification_version: 4
129
130
  summary: Rentability and financial calculations