jpx_industry_code 0.0.4 → 0.0.5
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/jpx_industry_code/category.rb +27 -2
- data/lib/jpx_industry_code/errors.rb +9 -0
- data/lib/jpx_industry_code.rb +30 -4
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04b18b13e739d6ea4a95dd3cb33f93bde63b499d4767aec7a0e80e17869f542a
|
4
|
+
data.tar.gz: c3080bc4f9708503250b0aed379f36e72df356b5f6330be63d249b1b96736c09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9842219e4dac4af698baa6c75ec9bc4c5f1f69b19ae290dfdc8dc429b517662b92e5af63f58cc7d0d538464e44dff9bf970c401d13168a43cba0d0492925f4f3
|
7
|
+
data.tar.gz: 14e6f41fec2e269d637427d7a3d9726cc111120b56340b775cabdba8856912a60fd330d9e823e48db9575e3dc7b058f5b655f8443946f71dc21de0967bdae85f
|
@@ -9,14 +9,39 @@ class JpxIndustryCode
|
|
9
9
|
{ id: 2, name: '鉱業' },
|
10
10
|
{ id: 3, name: '建設業' },
|
11
11
|
{ id: 4, name: '製造業' },
|
12
|
-
{ id: 5, name: '
|
12
|
+
{ id: 5, name: '電気・ガス業' },
|
13
13
|
{ id: 6, name: '運輸・情報通信業' },
|
14
14
|
{ id: 7, name: '商業' },
|
15
15
|
{ id: 8, name: '金融・保険業' },
|
16
16
|
{ id: 9, name: '不動産業' },
|
17
|
-
{ id: 10, name: '
|
17
|
+
{ id: 10, name: 'サービス業' }
|
18
18
|
]
|
19
19
|
end
|
20
|
+
|
21
|
+
def find_by!(find_option)
|
22
|
+
validate_find_option!(find_option)
|
23
|
+
|
24
|
+
all.find(raise_not_found) do |jpx_industry_code_category|
|
25
|
+
jpx_industry_code_category[find_option.flatten[0]] == find_option.flatten[1]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_by(find_option)
|
30
|
+
all.find do |jpx_industry_code_category|
|
31
|
+
jpx_industry_code_category[find_option.flatten[0]] == find_option.flatten[1]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def validate_find_option!(find_option)
|
38
|
+
raise JpxIndustryCode::Errors::InvalidArgumentError, ':id or :name must be specified.' if !find_option.is_a?(Hash) || (find_option[:id].nil? && find_option[:name].nil?)
|
39
|
+
raise JpxIndustryCode::Errors::InvalidArgumentError, 'Single keyword argument can be specified.' if find_option.keys.length > 1
|
40
|
+
end
|
41
|
+
|
42
|
+
def raise_not_found
|
43
|
+
proc { raise JpxIndustryCode::Errors::NotFoundError }
|
44
|
+
end
|
20
45
|
end
|
21
46
|
end
|
22
47
|
end
|
data/lib/jpx_industry_code.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'jpx_industry_code/category'
|
4
|
+
require 'jpx_industry_code/errors'
|
4
5
|
|
5
6
|
class JpxIndustryCode
|
6
7
|
class << self
|
@@ -11,12 +12,12 @@ class JpxIndustryCode
|
|
11
12
|
{ id: 3, jpx_industry_code_category_id: 3, name: '建設業', code: '2050' },
|
12
13
|
{ id: 4, jpx_industry_code_category_id: 4, name: '食料品', code: '3050' },
|
13
14
|
{ id: 5, jpx_industry_code_category_id: 4, name: '繊維製品', code: '3100' },
|
14
|
-
{ id: 6, jpx_industry_code_category_id: 4, name: '
|
15
|
+
{ id: 6, jpx_industry_code_category_id: 4, name: 'パルプ・紙', code: '3150' },
|
15
16
|
{ id: 7, jpx_industry_code_category_id: 4, name: '化学', code: '3200' },
|
16
17
|
{ id: 8, jpx_industry_code_category_id: 4, name: '医薬品', code: '3250' },
|
17
18
|
{ id: 9, jpx_industry_code_category_id: 4, name: '石油・石炭製品', code: '3300' },
|
18
|
-
{ id: 10, jpx_industry_code_category_id: 4, name: '
|
19
|
-
{ id: 11, jpx_industry_code_category_id: 4, name: '
|
19
|
+
{ id: 10, jpx_industry_code_category_id: 4, name: 'ゴム製品', code: '3350' },
|
20
|
+
{ id: 11, jpx_industry_code_category_id: 4, name: 'ガラス・土石製品', code: '3400' },
|
20
21
|
{ id: 12, jpx_industry_code_category_id: 4, name: '鉄鋼', code: '3450' },
|
21
22
|
{ id: 13, jpx_industry_code_category_id: 4, name: '非鉄金属', code: '3500' },
|
22
23
|
{ id: 14, jpx_industry_code_category_id: 4, name: '金属製品', code: '3550' },
|
@@ -38,8 +39,33 @@ class JpxIndustryCode
|
|
38
39
|
{ id: 30, jpx_industry_code_category_id: 8, name: '保険業', code: '7150' },
|
39
40
|
{ id: 31, jpx_industry_code_category_id: 8, name: 'その他金融業', code: '7200' },
|
40
41
|
{ id: 32, jpx_industry_code_category_id: 9, name: '不動産業', code: '8050' },
|
41
|
-
{ id: 33, jpx_industry_code_category_id: 10, name: '
|
42
|
+
{ id: 33, jpx_industry_code_category_id: 10, name: 'サービス業', code: '9050' }
|
42
43
|
]
|
43
44
|
end
|
45
|
+
|
46
|
+
def find_by!(find_option)
|
47
|
+
validate_find_option!(find_option)
|
48
|
+
|
49
|
+
all.find(raise_not_found) do |jpx_industry_code|
|
50
|
+
jpx_industry_code[find_option.flatten[0]] == find_option.flatten[1]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def find_by(find_option)
|
55
|
+
all.find do |jpx_industry_code|
|
56
|
+
jpx_industry_code[find_option.flatten[0]] == find_option.flatten[1]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def validate_find_option!(find_option)
|
63
|
+
raise JpxIndustryCode::Errors::InvalidArgumentError, ':id, :name or :code must be specified.' if !find_option.is_a?(Hash) || (find_option[:id].nil? && find_option[:name].nil? && find_option[:code].nil?)
|
64
|
+
raise JpxIndustryCode::Errors::InvalidArgumentError, 'Single keyword argument can be specified.' if find_option.keys.length > 1
|
65
|
+
end
|
66
|
+
|
67
|
+
def raise_not_found
|
68
|
+
proc { raise JpxIndustryCode::Errors::NotFoundError }
|
69
|
+
end
|
44
70
|
end
|
45
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jpx_industry_code
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rui Onodera
|
@@ -18,6 +18,7 @@ extra_rdoc_files: []
|
|
18
18
|
files:
|
19
19
|
- lib/jpx_industry_code.rb
|
20
20
|
- lib/jpx_industry_code/category.rb
|
21
|
+
- lib/jpx_industry_code/errors.rb
|
21
22
|
homepage: https://github.com/ai-capital/jpx_industry_code
|
22
23
|
licenses:
|
23
24
|
- MIT
|