fe_core_ext 0.26.0 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fe_core_ext/core_ext/array.rb +2 -0
- data/lib/fe_core_ext/core_ext/csv.rb +3 -1
- data/lib/fe_core_ext/core_ext/date.rb +11 -9
- data/lib/fe_core_ext/core_ext/hash.rb +4 -2
- data/lib/fe_core_ext/core_ext/integer.rb +2 -0
- data/lib/fe_core_ext/core_ext/numeric.rb +2 -0
- data/lib/fe_core_ext/core_ext/pathname.rb +2 -0
- data/lib/fe_core_ext/core_ext/string.rb +2 -0
- data/lib/fe_core_ext/core_ext/time.rb +2 -0
- data/lib/fe_core_ext/core_ext/uri.rb +2 -0
- data/lib/fe_core_ext/version.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b2edebd6960c44f5de6228de9682e38dbc1d6a658b61baf95e251f07db72260
|
4
|
+
data.tar.gz: 0c207c390e5af9e6e744e293e6157928cdd33a67a07ec2d8a4c8ba7795136a80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1396d80d727d6720063348505085bcc74ec21c26b1fa2ad3bc484a83c2be53c2d4874881c15b803b39826a08667110be30519215930c4b7e64836a5c16f82b8
|
7
|
+
data.tar.gz: f086416a4ecfa3247886c6da78d6cc458ddbdde87a8b4e62a2c7618de84d6279d603eb2dc1ac11043553cd43dd0d1450b6d2535333bae884d7f175391c54d2d7
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support'
|
2
4
|
require 'active_support/time'
|
3
5
|
|
@@ -18,9 +20,9 @@ module FeCoreExt::CoreExt::Date
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def nth_weekday(nth, weekday)
|
21
|
-
first_day = Date.new(
|
22
|
-
weekdays_hash = {sun: 0, mon: 1, tue: 2, wed: 3, thu: 4, fri: 5, sat: 6}
|
23
|
-
weekday_dates = (first_day..first_day.end_of_month).select{|d| d.wday == weekdays_hash[weekday]}
|
23
|
+
first_day = Date.new(year, month, 1)
|
24
|
+
weekdays_hash = { sun: 0, mon: 1, tue: 2, wed: 3, thu: 4, fri: 5, sat: 6 }
|
25
|
+
weekday_dates = (first_day..first_day.end_of_month).select { |d| d.wday == weekdays_hash[weekday] }
|
24
26
|
weekday_dates[nth - 1]
|
25
27
|
end
|
26
28
|
end
|
@@ -29,6 +31,7 @@ module FeCoreExt::CoreExt::DateClassMethods
|
|
29
31
|
def parsable?(string)
|
30
32
|
parsed_hash = _parse(string)
|
31
33
|
return true if parsed_hash.has_key?(:year) && parsed_hash.has_key?(:mon)
|
34
|
+
|
32
35
|
false
|
33
36
|
end
|
34
37
|
|
@@ -39,15 +42,15 @@ module FeCoreExt::CoreExt::DateClassMethods
|
|
39
42
|
|
40
43
|
def parse_heisei(string)
|
41
44
|
string.match('平成(\d+)年(\d+)月(\d+)日') do
|
42
|
-
Date.new(
|
45
|
+
Date.new(::Regexp.last_match(1).to_i + 1988, ::Regexp.last_match(2).to_i, ::Regexp.last_match(3).to_i)
|
43
46
|
end
|
44
47
|
end
|
45
48
|
|
46
49
|
def parse_reiwa(string)
|
47
50
|
string.match('令和(\S+)年(\d+)月(\d+)日') do
|
48
|
-
year = 1 if
|
49
|
-
year ||=
|
50
|
-
Date.new(year + 2018,
|
51
|
+
year = 1 if ::Regexp.last_match(1) == '元'
|
52
|
+
year ||= ::Regexp.last_match(1).to_i
|
53
|
+
Date.new(year + 2018, ::Regexp.last_match(2).to_i, ::Regexp.last_match(3).to_i)
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
@@ -57,14 +60,13 @@ module FeCoreExt::CoreExt::DateClassMethods
|
|
57
60
|
|
58
61
|
def parse_nengappi(string)
|
59
62
|
string.match(/(\d{4})年(\d+)月(\d+)日/) do
|
60
|
-
|
63
|
+
Date.new(::Regexp.last_match(1).to_i, ::Regexp.last_match(2).to_i, ::Regexp.last_match(3).to_i)
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
64
67
|
def parse_ja(string)
|
65
68
|
parse_nengappi(string) || parse_gengo(string)
|
66
69
|
end
|
67
|
-
|
68
70
|
end
|
69
71
|
|
70
72
|
class Date
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support'
|
2
4
|
require 'active_support/core_ext/hash'
|
3
5
|
|
@@ -5,8 +7,8 @@ module FeCoreExt::CoreExt
|
|
5
7
|
end
|
6
8
|
|
7
9
|
module FeCoreExt::CoreExt::Hash
|
8
|
-
def
|
9
|
-
transform_keys { |key| key.to_s.
|
10
|
+
def snake_symbolize_keys
|
11
|
+
transform_keys { |key| key.to_s.snakecase.to_sym }
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
data/lib/fe_core_ext/version.rb
CHANGED