fat_core 2.0.0 → 2.0.1
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 +4 -4
- data/lib/fat_core/array.rb +8 -7
- data/lib/fat_core/date.rb +4 -4
- data/lib/fat_core/version.rb +1 -1
- data/spec/lib/array_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da78308a426ec42f9920c3d5ca369c42abbe115b
|
4
|
+
data.tar.gz: 91924adb3efec242ed5f1a2ad2db9d4c90cc5c27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fbef2316f1716b2ee05235d328496143c16d779574a753cb4ffd027da713b72873eb85200c0530695b606b684418d337d18713d02723505f94d9525f7462369
|
7
|
+
data.tar.gz: 6fa8b41ea91fa61421fc7707e6529cc1b786f408b6d4328338af6f945b6af979c1d4f94848ea3a893c66c05565f5198bed00bfde3572007751322f776b8413c5
|
data/lib/fat_core/array.rb
CHANGED
@@ -4,7 +4,9 @@ class Array
|
|
4
4
|
end
|
5
5
|
|
6
6
|
# Return a new array that is the intersection of this Array with other, but
|
7
|
-
# without removing duplicates as the :& method does.
|
7
|
+
# without removing duplicates as the :& method does. All items of the first
|
8
|
+
# array are included in the result but only if they also appear in the other
|
9
|
+
# array.
|
8
10
|
def intersect(other)
|
9
11
|
result = []
|
10
12
|
each do |itm|
|
@@ -14,13 +16,12 @@ class Array
|
|
14
16
|
end
|
15
17
|
|
16
18
|
# Return an array that is the difference between this Array and the other, but
|
17
|
-
# without removing duplicates as the :- method does.
|
19
|
+
# without removing duplicates as the :- method does. All items of the first
|
20
|
+
# array are included in the result unless they also appear in the other array.
|
18
21
|
def difference(other)
|
19
|
-
result =
|
20
|
-
|
21
|
-
|
22
|
-
result.delete_at(k)
|
23
|
-
end
|
22
|
+
result = []
|
23
|
+
each do |itm|
|
24
|
+
result << itm unless other.include?(itm)
|
24
25
|
end
|
25
26
|
result
|
26
27
|
end
|
data/lib/fat_core/date.rb
CHANGED
@@ -869,7 +869,7 @@ class Date
|
|
869
869
|
# They NYSE has closed on several occasions outside its normal holiday
|
870
870
|
# rules. This detects those dates beginning in 1960. Closing for part of a
|
871
871
|
# day is not counted. See http://www1.nyse.com/pdfs/closings.pdf
|
872
|
-
def nyse_special_holiday
|
872
|
+
def nyse_special_holiday?
|
873
873
|
return false unless self > Date.parse('1960-01-01')
|
874
874
|
case self
|
875
875
|
when Date.parse('1961-05-29')
|
@@ -942,7 +942,7 @@ class Date
|
|
942
942
|
# Is self a fixed holiday
|
943
943
|
return true if nyse_fixed_holiday? || nyse_moveable_feast?
|
944
944
|
|
945
|
-
return true if nyse_special_holiday
|
945
|
+
return true if nyse_special_holiday?
|
946
946
|
|
947
947
|
if friday? && (self >= Date.parse('1959-07-03'))
|
948
948
|
# A Friday is a holiday if a holiday would fall on the following
|
@@ -1018,7 +1018,7 @@ class Date
|
|
1018
1018
|
# Return self if its a trading day, otherwise skip back to the first prior
|
1019
1019
|
# trading day.
|
1020
1020
|
def prior_until_trading_day
|
1021
|
-
date =
|
1021
|
+
date = dup
|
1022
1022
|
date -= 1 until date.trading_day?
|
1023
1023
|
date
|
1024
1024
|
end
|
@@ -1026,7 +1026,7 @@ class Date
|
|
1026
1026
|
# Return self if its a trading day, otherwise skip forward to the first
|
1027
1027
|
# later trading day.
|
1028
1028
|
def next_until_trading_day
|
1029
|
-
date =
|
1029
|
+
date = dup
|
1030
1030
|
date += 1 until date.trading_day?
|
1031
1031
|
date
|
1032
1032
|
end
|
data/lib/fat_core/version.rb
CHANGED
data/spec/lib/array_spec.rb
CHANGED
@@ -15,10 +15,10 @@ describe Array do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'difference' do
|
18
|
-
expect(%w(A A B A C A B).difference(%w(A B A))).to eq(%w(
|
19
|
-
expect(%w(A A B A C A B).difference(%w(A B))).to eq(%w(
|
20
|
-
expect(%w(A A B A C A B).difference(%w(A))).to eq(%w(
|
21
|
-
expect(%w(A A B A C A B).difference(%w(B))).to eq(%w(A A A C A
|
18
|
+
expect(%w(A A B A C A B).difference(%w(A B A))).to eq(%w(C))
|
19
|
+
expect(%w(A A B A C A B).difference(%w(A B))).to eq(%w(C))
|
20
|
+
expect(%w(A A B A C A B).difference(%w(A))).to eq(%w(B C B))
|
21
|
+
expect(%w(A A B A C A B).difference(%w(B))).to eq(%w(A A A C A))
|
22
22
|
expect(%w(A A B A C A B).difference(%w(C))).to eq(%w(A A B A A B))
|
23
23
|
end
|
24
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fat_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel E. Doherty
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|