fe_core_ext 0.13.1 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d73ff1e3330a404b7c2d2b1b8194770774963351df63355a9248e9ea386f1ab
4
- data.tar.gz: ec4a5a0d73267c7888f4d34281a72eeba98666a1dbaddb3fe0039fe8aba248e5
3
+ metadata.gz: 5a02ed1927dc5c71d08be535561898efd8b3942bb3c4c5fe496b017fbeea10db
4
+ data.tar.gz: 75a8ebae9e7b28cedab17678af81607f23e7823dc0da626189b71a7c201494d8
5
5
  SHA512:
6
- metadata.gz: 9e90a09d47bdd8f4fb5d66048cb4b3fee78716dbf7d5833ecb5705bd1f14c27ce8c6a4ee8c637dea1ee450d7d6418fae8791ac37b4bbc836c3d3d0451c2bae08
7
- data.tar.gz: aea51cb43dbf5331531d93db23f8acc015ee4b35881953f36137d5f6e41cbd3b817b60f8bab445ec68e3eeead2a9bbdbd938e7aaeeb0238559bef8196003922d
6
+ metadata.gz: 934b8426763094548f9790ba4f5d3aad54f6f352ffcdbac9a39b8f07963258f123638b8161ace32cee8486449a1063f1b3fadb0e3b1adedbdb9bf53a06a91843
7
+ data.tar.gz: 788b536fdfd5e7c6462aabd4077ca85388ae7e65983f16bf818d0fd36642757cd5919ab0241f494f8e20bd1acfa987820c217c4bcbc7a3deadbd57dd7c9d0b8d
@@ -34,22 +34,33 @@ module FeCoreExt::CoreExt::DateClassMethods
34
34
  end
35
35
 
36
36
  def parse_heisei(string)
37
- string.match('平成(\d+)年(\d+)月(\d+)日') {
37
+ string.match('平成(\d+)年(\d+)月(\d+)日') do
38
38
  Date.new($1.to_i + 1988, $2.to_i, $3.to_i)
39
- }
39
+ end
40
40
  end
41
41
 
42
42
  def parse_reiwa(string)
43
- string.match('令和(\S+)年(\d+)月(\d+)日') {
43
+ string.match('令和(\S+)年(\d+)月(\d+)日') do
44
44
  year = 1 if $1 == '元'
45
45
  year ||= $1.to_i
46
46
  Date.new(year + 2018, $2.to_i, $3.to_i)
47
- }
47
+ end
48
48
  end
49
49
 
50
50
  def parse_gengo(string)
51
51
  parse_heisei(string) || parse_reiwa(string)
52
52
  end
53
+
54
+ def parse_nengappi(string)
55
+ string.match(/(\d{4})年(\d+)月(\d+)日/) do
56
+ Date.new($1.to_i, $2.to_i, $3.to_i)
57
+ end
58
+ end
59
+
60
+ def parse_ja(string)
61
+ parse_nengappi(string) || parse_gengo(string)
62
+ end
63
+
53
64
  end
54
65
 
55
66
  class Date
@@ -12,11 +12,21 @@ module FeCoreExt::CoreExt::String
12
12
  delete(',').to_i
13
13
  end
14
14
 
15
+ def to_integer_new
16
+ return unless valid_number?
17
+ delete(',').to_i
18
+ end
19
+
15
20
  def to_decimal
16
21
  return if not_number?
17
22
  delete(',').to_d
18
23
  end
19
24
 
25
+ def to_decimal_new
26
+ return unless valid_number?
27
+ delete(',').to_d
28
+ end
29
+
20
30
  def to_pathname
21
31
  Pathname(self)
22
32
  end
@@ -25,6 +35,10 @@ module FeCoreExt::CoreExt::String
25
35
  to_i == 0 && match('0').nil?
26
36
  end
27
37
 
38
+ def valid_number?
39
+ match?(/^[\d\,\.]+$/)
40
+ end
41
+
28
42
  ## deprecated
29
43
  def zen_to_han
30
44
  tr('0-9A-Za-z &・-()', '0-9A-Za-z &・\-()')
@@ -1,3 +1,3 @@
1
1
  module FeCoreExt
2
- VERSION = '0.13.1'
2
+ VERSION = '0.15.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fe_core_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tetsu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-06 00:00:00.000000000 Z
11
+ date: 2022-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport