gengo_search 0.1.1 → 0.1.2

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
2
  SHA256:
3
- metadata.gz: 83e8f194429245645e59648ff37ed5cda9c325b98394e28628643f62d9f4e687
4
- data.tar.gz: 137663688eef2a40bf053c099c3413b20c12ff24bce64f5946f8b6465088e57c
3
+ metadata.gz: 1b21f0d497d205973249398d7e5999f8ad5bfed5c2711b54f74ea761f8dbbecd
4
+ data.tar.gz: '082db8528b63968e6c4ecdc72ed91d7d9aac40e417789c91e2dce805bd0b3eb7'
5
5
  SHA512:
6
- metadata.gz: fb5f231c573596e9dfc658a200721a5d9819548eae1513b3659cf2523985c622a4f5c17af27eb671d60c6bdc4d7e9c6e16f58f450e7f542834a149849d224bad
7
- data.tar.gz: 10e313e27172b353267167ce12378faefbf4bd4bf4f2fed4ffb197f1cc909a802086654aaecb943916c7ae47c46e784c16c2b514345b8a872c8d01a90f53387a
6
+ metadata.gz: db8fccee7b09d328a6ddfc08f1ef54222bc74d42590183e3fed71e2596e7608423a4ba6769bd7493e9641935630d28c1afd2a172390c68a03ab40d4cf8f6d1b2
7
+ data.tar.gz: bf3aeda3ee5ce5aa1eb8f67b8a4dc74a2c87c6371fa450cce11228ac7c58c6bca258380100c2b5ed5248d2ca4ad110d3433c8712d731b6f7ff4baa4e0ad11611
data/.gitignore CHANGED
@@ -1,11 +1,11 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -1,7 +1,7 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.5.3
7
- before_install: gem install bundler -v 2.0.1
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 2.0.1
@@ -1,74 +1,74 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at TODO: Write your email address. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at TODO: Write your email address. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in gengo_search.gemspec
4
- gemspec
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gengo_search.gemspec
4
+ gemspec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gengo_search (0.1.1)
4
+ gengo_search (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2019 TODO: Write your name
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,51 +1,51 @@
1
- # GengoSearch
2
-
3
- GengoSearch is a gem to convert Anno Domini year like 1989 to Japanese era name like HEISEI, MEIJI and so on.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'gengo_search'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install gengo_search
20
-
21
- ## Usage
22
-
23
- Set year(YYYY) you want to convert when create new instance.
24
- Do note that First Japanese era starts from 645. So if you choose less than 645, it returns ArgumentError.
25
-
26
- Once an instance created, you can get Japanese era name by Kanji, Romaji, or Hiragana as below.
27
-
28
- ```ruby
29
- gengo = GengoSearch::Gengo.new(1900)
30
- gengo.kanji #=> "明治 33年"
31
- gengo.romaji #=> "MEIJI 33NEN"
32
- gengo.hiragana #=> "めいじ 33ねん"
33
- ```
34
-
35
- ## Development
36
-
37
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
-
39
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
-
41
- ## Contributing
42
-
43
- Bug reports and pull requests are welcome on GitHub at https://github.com/shoyu777/gengo_search. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
44
-
45
- ## License
46
-
47
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
48
-
49
- ## Code of Conduct
50
-
51
- Everyone interacting in the GengoSearch project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/shoyu777/gengo_search/blob/master/CODE_OF_CONDUCT.md).
1
+ # GengoSearch
2
+
3
+ GengoSearch is a gem to convert Anno Domini year like 1989 to Japanese era name like HEISEI, MEIJI and so on.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'gengo_search'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install gengo_search
20
+
21
+ ## Usage
22
+
23
+ Set year(YYYY) you want to convert when create new instance.
24
+ Do note that First Japanese era starts from 645. So if you choose less than 645, it returns ArgumentError.
25
+
26
+ Once an instance created, you can get Japanese era name by Kanji, Romaji, or Hiragana as below.
27
+
28
+ ```ruby
29
+ gengo = GengoSearch::Gengo.new(1900)
30
+ gengo.kanji #=> "明治 33年"
31
+ gengo.romaji #=> "MEIJI 33NEN"
32
+ gengo.hiragana #=> "めいじ 33ねん"
33
+ ```
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+
39
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/shoyu777/gengo_search. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
48
+
49
+ ## Code of Conduct
50
+
51
+ Everyone interacting in the GengoSearch project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/shoyu777/gengo_search/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "gengo_search"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gengo_search"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -1,29 +1,29 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "gengo_search/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "gengo_search"
8
- spec.version = GengoSearch::VERSION
9
- spec.authors = ["shoyu777"]
10
- spec.email = [""]
11
-
12
- spec.summary = %q{Convert Anno Domini to Japanese era name.}
13
- spec.description = %q{Convert Anno Domini to Japanese era name.}
14
- spec.homepage = "https://github.com/shoyu777/gengo_search"
15
- spec.license = "MIT"
16
-
17
- # Specify which files should be added to the gem when it is released.
18
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
- end
22
- spec.bindir = "exe"
23
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
- spec.require_paths = ["lib"]
25
-
26
- spec.add_development_dependency "bundler", "~> 2.0"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "rspec", "~> 3.0"
29
- end
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "gengo_search/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gengo_search"
8
+ spec.version = GengoSearch::VERSION
9
+ spec.authors = ["shoyu777"]
10
+ spec.email = [""]
11
+
12
+ spec.summary = %q{Convert Anno Domini to Japanese era name.}
13
+ spec.description = %q{Convert Anno Domini to Japanese era name.}
14
+ spec.homepage = "https://github.com/shoyu777/gengo_search"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 2.0"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ end
@@ -1,238 +1,239 @@
1
- 645,大化,TAIKA,たいか
2
- 650,白雉,HAKUCHI,はくち
3
- 686,朱鳥,SHUCHO,しゅちょう
4
- 701,大宝,TAIHO,たいほう
5
- 704,慶雲,KEIUN,けいうん
6
- 708,和銅,WADO,わどう
7
- 715,霊亀,REIKI,れいき
8
- 717,養老,YORO,ようろう
9
- 724,神亀,JINKI,じんき
10
- 729,天平,TEMPYO,てんぴょう
11
- 749,天平感宝,TEMPYOKAMPO,てんぴょうかんぽう
12
- 749,天平勝宝,TEMPYOSHOHO,てんぴょうしょうほう
13
- 757,天平宝字,TEMPYOHOJI,てんぴょうほうじ
14
- 765,天平神護,TEMPYOJINGO,てんぴょうじんご
15
- 767,神護景雲,JINGOKEIUN,じんごけいうん
16
- 770,宝亀,HOKI,ほうき
17
- 781,天応,TENNO,てんのう
18
- 782,延暦,ENRYAKU,えんりゃく
19
- 806,大同,DAIDO,だいどう
20
- 810,弘仁,KONIN,こうにん
21
- 824,天長,TENCHO,てんちょう
22
- 834,承和,JOWA,じょうわ
23
- 848,嘉祥,KASHO,かしょう
24
- 851,仁寿,NINJU,にんじゅ
25
- 854,斉衡,SAIKO,さいこう
26
- 857,天安,TENAN,てんあん
27
- 859,貞観,JOGAN,じょうがん
28
- 877,元慶,GANGYO,がんぎょう
29
- 885,仁和,NINNA,にんな
30
- 889,寛平,KAMPYO,かんぴょう
31
- 898,昌泰,SHOTAI,しょうたい
32
- 901,延喜,ENGI,えんぎ
33
- 923,延長,ENCHO,えんちょう
34
- 931,承平,JOHEI,じょうへい
35
- 938,天慶,TENGYO,てんぎょう
36
- 947,天暦,TENRYAKU,てんりゃく
37
- 957,天徳,TENTOKU,てんとく
38
- 961,応和,OWA,おうわ
39
- 964,康保,KOHO,こうほう
40
- 968,安和,ANNA,あんな
41
- 970,天禄,TENROKU,てんろく
42
- 973,天延,TENEN,てんえん
43
- 976,貞元,JOGEN,じょうげん
44
- 978,天元,TENGEN,てんげん
45
- 983,永観,EIKAN,えいかん
46
- 984,寛和,KANNA,かんな
47
- 987,永延,EIEN,えいえん
48
- 989,永祚,EISO,えいそ
49
- 990,正暦,SHORYAKU,しょうりゃく
50
- 995,長徳,CHOTOKU,ちょうとく
51
- 999,長保,CHOHO,ちょうほ
52
- 1004,寛弘,KANKO,かんこう
53
- 1012,長和,CHOWA,ちょうわ
54
- 1017,寛仁,KANNIN,かんにん
55
- 1021,治安,JIAN,じあん
56
- 1024,万寿,MANJU,まんじゅ
57
- 1028,長元,CHOGEN,ちょうげん
58
- 1037,長暦,CHORYAKU,ちょうりゃく
59
- 1040,長久,CHOKYU,ちょうきゅう
60
- 1044,寛徳,KANTOKU,かんとく
61
- 1046,永承,EISHO,えいしょう
62
- 1053,天喜,TENGI,てんぎ
63
- 1058,康平,KOHEI,こうへい
64
- 1065,治暦,JIRYAKU,じりゃく
65
- 1069,延久,ENKYU,えんきゅう
66
- 1074,承保,SHOHO,しょうほう
67
- 1077,承暦,SHORYAKU,しょうりゃく
68
- 1081,永保,EIHO,えいほ
69
- 1084,応徳,OTOKU,おうとく
70
- 1087,寛治,KANJI,かんじ
71
- 1094,嘉保,KAHO,かほう
72
- 1096,永長,EICHO,えいちょう
73
- 1097,承徳,SHOTOKU,しょうとく
74
- 1099,康和,KOWA,こうわ
75
- 1104,長治,CHOJI,ちょうじ
76
- 1106,嘉承,KAJO,かじょう
77
- 1108,天仁,TENNIN,てんにん
78
- 1110,天永,TENEI,てんえい
79
- 1113,永久,EIKYU,えいきゅう
80
- 1118,元永,GENEI,げんえい
81
- 1120,保安,HOAN,ほうあん
82
- 1124,天治,TENJI,てんじ
83
- 1126,大治,TAIJI,たいじ
84
- 1131,天承,TENSHO,てんしょう
85
- 1132,長承,CHOSHO,ちょうしょう
86
- 1135,保延,HOEN,ほうえん
87
- 1141,永治,EIJI,えいじ
88
- 1142,康治,KOJI,こうじ
89
- 1144,天養,TENYO,てんよう
90
- 1145,久安,KYUAN,きゅうあん
91
- 1151,仁平,NIMPYO,にんぴょう
92
- 1154,久寿,KYUJU,きゅうじゅ
93
- 1156,保元,HOGEN,ほうげん
94
- 1159,平治,HEIJI,へいじ
95
- 1160,永暦,EIRYAKU,えいりゃく
96
- 1161,応保,OHO,おうほ
97
- 1163,長寛,CHOKAN,ちょうかん
98
- 1165,永万,EIMAN,えいまん
99
- 1166,仁安,NINAN,にんあん
100
- 1169,嘉応,KAO,かおう
101
- 1171,承安,JOAN,じょうあん
102
- 1175,安元,ANGEN,あんげん
103
- 1177,治承,JISHO,じしょう
104
- 1181,養和,YOWA,ようわ
105
- 1182,寿永,JUEI,じゅえい
106
- 1184,元暦,GENRYAKU,げんりゃく
107
- 1185,文治,BUNJI,ぶんじ
108
- 1190,建久,KENKYU,けんきゅう
109
- 1199,正治,SHOJI,しょうじ
110
- 1201,建仁,KENNIN,けんにん
111
- 1204,元久,GENKYU,げんきゅう
112
- 1206,建永,KENEI,けんえい
113
- 1207,承元,SHOGEN,しょうげん
114
- 1211,建暦,KENRYAKU,けんりゃく
115
- 1213,健保,KEMPO,けんぽ
116
- 1219,承久,JOKYU,じょうきゅう
117
- 1222,貞応,JOO,じょうおう
118
- 1224,元仁,GENNIN,げんにん
119
- 1225,嘉禄,KAROKU,かろく
120
- 1227,安貞,ANTEI,あんてい
121
- 1229,寛喜,KANGI,かんぎ
122
- 1232,貞永,JOEI,じょうえい
123
- 1233,天福,TEMPUKU,てんぷく
124
- 1234,文暦,BUNRYAKU,ぶんりゃく
125
- 1235,嘉禎,KATEI,かてい
126
- 1238,暦仁,RYAKUNIN,りゃくにん
127
- 1239,延応,ENNO,えんのう
128
- 1240,仁治,NINJI,にんじ
129
- 1243,寛元,KANGEN,かんげん
130
- 1247,宝治,HOJI,ほうじ
131
- 1249,建長,KENCHO,けんちょう
132
- 1256,康元,KOGEN,こうげん
133
- 1257,正嘉,SHOKA,しょうか
134
- 1259,正元,SHOGEN,しょうげん
135
- 1260,文応,BUNO,ぶんおう
136
- 1261,弘長,KOCHO,こうちょう
137
- 1264,文永,BUNEI,ぶんえい
138
- 1275,建治,KENJI,けんじ
139
- 1278,弘安,KOAN,こうあん
140
- 1288,正応,SHOO,しょうおう
141
- 1293,永仁,EININ,えいにん
142
- 1299,正安,SHOAN,しょうあん
143
- 1302,乾元,KENGEN,けんげん
144
- 1303,嘉元,KAGEN,かげん
145
- 1306,徳治,TOKUJI,とくじ
146
- 1308,延慶,ENKYO,えんきょう
147
- 1311,応長,OCHO,おうちょう
148
- 1312,正和,SHOWA,しょうわ
149
- 1317,文保,BUMPO,ぶんぽ
150
- 1319,元応,GENO,げんおう
151
- 1321,元亨,GENKO,げんこう
152
- 1324,正中,SHOCHU,しょうちゅう
153
- 1326,嘉暦,KARYAKU,かりゃく
154
- 1329,元徳,GENTOKU,げんとく
155
- 1331,元弘,GENKO,げんこう
156
- 1329,元徳,GENTOKU,げんとく
157
- 1332,正慶,SHOKYO,しょうきょう
158
- 1334,建武,KEMMU,けんむ
159
- 1338,暦応,RYAKUO,りゃくおう
160
- 1342,康永,KOEI,こうえい
161
- 1345,貞和,JOWA,じょうわ
162
- 1350,観応,KANNO,かんのう
163
- 1352,文和,BUNNA,ぶんな
164
- 1356,延文,EMBUN,えんぶん
165
- 1361,康安,KOAN,こうあん
166
- 1362,貞治,JOJI,じょうじ
167
- 1368,応安,OAN,おうあん
168
- 1375,永和,EIWA,えいわ
169
- 1379,康暦,KORYAKU,こうりゃく
170
- 1381,永徳,EITOKU,えいとく
171
- 1384,至徳,SHITOKU,しとく
172
- 1387,嘉慶,KAKYO,かきょう
173
- 1389,康応,KOO,こうおう
174
- 1390,明徳,MEITOKU,めいとく
175
- 1428,応永,OEI,おうえい
176
- 1429,永享,EIKYO,えいきょう
177
- 1441,嘉吉,KAKITSU,かきつ
178
- 1444,文安,BUNAN,ぶんあん
179
- 1449,宝徳,HOTOKU,ほうとく
180
- 1455,康正,KOSHO,こうしょう
181
- 1457,長禄,CHOROKU,ちょうろく
182
- 1460,寛正,KANSHO,かんしょう
183
- 1466,文正,BUNSHO,ぶんしょう
184
- 1467,応仁,ONIN,おうにん
185
- 1469,文明,BUMMEI,ぶんめい
186
- 1487,長享,CHOKYO,ちょうきょう
187
- 1489,延徳,ENTOKU,えんとく
188
- 1492,明応,MEIO,めいおう
189
- 1501,文亀,BUNKI,ぶんき
190
- 1504,永正,EISHO,えいしょう
191
- 1521,大永,TAIEI,たいえい
192
- 1528,享禄,KYOROKU,きょうろく
193
- 1532,天文,TEMBUN,てんぶん
194
- 1555,弘治,KOJI,こうじ
195
- 1558,永禄,EIROKU,えいろく
196
- 1570,元亀,GENKI,げんき
197
- 1573,天正,TENSHO,てんしょう
198
- 1592,文禄,BUNROKU,ぶんろく
199
- 1596,慶長,KEICHO,けいちょう
200
- 1615,元和,GENNA,げんな
201
- 1624,寛永,KANEI,かんえい
202
- 1644,正保,SHOHO,しょうほ
203
- 1648,慶安,KEIAN,けいあん
204
- 1652,承応,JOO,じょうおう
205
- 1655,明暦,MEIREKI,めいれき
206
- 1658,万治,MANJI,まんじ
207
- 1661,寛文,KAMBUN,かんぶん
208
- 1673,延宝,EMPO,えんぽう
209
- 1681,天和,TENNA,てんな
210
- 1684,貞享,JOKYO,じょうきょう
211
- 1688,元禄,GENROKU,げんろく
212
- 1704,宝永,HOEI,ほうえい
213
- 1711,正徳,SHOTOKU,しょうとく
214
- 1816,享保,KYOHO,きょうほう
215
- 1736,元文,GEMBUN,げんぶん
216
- 1741,寛保,KAMPO,かんぽう
217
- 1744,延享,ENKYO,えんきょう
218
- 1748,寛延,KANEN,かんえん
219
- 1751,宝暦,HOREKI,ほうれき
220
- 1764,明和,MEIWA,めいわ
221
- 1772,安永,ANEI,あんえい
222
- 1781,天明,TEMMEI,てんめい
223
- 1789,寛政,KANSEI,かんせい
224
- 1801,享和,KYOWA,きょうわ
225
- 1804,文化,BUNKA,ぶんか
226
- 1818,文政,BUNSEI,ぶんせい
227
- 1830,天保,TEMPO,てんぽう
228
- 1844,弘化,KOKA,こうか
229
- 1848,嘉永,KAEI,かえい
230
- 1854,安政,ANSEI,あんせい
231
- 1860,万延,MANEN,まんえん
232
- 1861,文久,BUNKYU,ぶんきゅう
233
- 1864,元治,GENJI,げんじ
234
- 1865,慶応,KEIO,けいおう
235
- 1868,明治,MEIJI,めいじ
236
- 1912,大正,TAISHO,たいしょう
237
- 1926,昭和,SHOWA,しょうわ
238
- 1989,平成,HEISEI,へいせい
1
+ 645,大化,TAIKA,たいか
2
+ 650,白雉,HAKUCHI,はくち
3
+ 686,朱鳥,SHUCHO,しゅちょう
4
+ 701,大宝,TAIHO,たいほう
5
+ 704,慶雲,KEIUN,けいうん
6
+ 708,和銅,WADO,わどう
7
+ 715,霊亀,REIKI,れいき
8
+ 717,養老,YORO,ようろう
9
+ 724,神亀,JINKI,じんき
10
+ 729,天平,TEMPYO,てんぴょう
11
+ 749,天平感宝,TEMPYOKAMPO,てんぴょうかんぽう
12
+ 749,天平勝宝,TEMPYOSHOHO,てんぴょうしょうほう
13
+ 757,天平宝字,TEMPYOHOJI,てんぴょうほうじ
14
+ 765,天平神護,TEMPYOJINGO,てんぴょうじんご
15
+ 767,神護景雲,JINGOKEIUN,じんごけいうん
16
+ 770,宝亀,HOKI,ほうき
17
+ 781,天応,TENNO,てんのう
18
+ 782,延暦,ENRYAKU,えんりゃく
19
+ 806,大同,DAIDO,だいどう
20
+ 810,弘仁,KONIN,こうにん
21
+ 824,天長,TENCHO,てんちょう
22
+ 834,承和,JOWA,じょうわ
23
+ 848,嘉祥,KASHO,かしょう
24
+ 851,仁寿,NINJU,にんじゅ
25
+ 854,斉衡,SAIKO,さいこう
26
+ 857,天安,TENAN,てんあん
27
+ 859,貞観,JOGAN,じょうがん
28
+ 877,元慶,GANGYO,がんぎょう
29
+ 885,仁和,NINNA,にんな
30
+ 889,寛平,KAMPYO,かんぴょう
31
+ 898,昌泰,SHOTAI,しょうたい
32
+ 901,延喜,ENGI,えんぎ
33
+ 923,延長,ENCHO,えんちょう
34
+ 931,承平,JOHEI,じょうへい
35
+ 938,天慶,TENGYO,てんぎょう
36
+ 947,天暦,TENRYAKU,てんりゃく
37
+ 957,天徳,TENTOKU,てんとく
38
+ 961,応和,OWA,おうわ
39
+ 964,康保,KOHO,こうほう
40
+ 968,安和,ANNA,あんな
41
+ 970,天禄,TENROKU,てんろく
42
+ 973,天延,TENEN,てんえん
43
+ 976,貞元,JOGEN,じょうげん
44
+ 978,天元,TENGEN,てんげん
45
+ 983,永観,EIKAN,えいかん
46
+ 984,寛和,KANNA,かんな
47
+ 987,永延,EIEN,えいえん
48
+ 989,永祚,EISO,えいそ
49
+ 990,正暦,SHORYAKU,しょうりゃく
50
+ 995,長徳,CHOTOKU,ちょうとく
51
+ 999,長保,CHOHO,ちょうほ
52
+ 1004,寛弘,KANKO,かんこう
53
+ 1012,長和,CHOWA,ちょうわ
54
+ 1017,寛仁,KANNIN,かんにん
55
+ 1021,治安,JIAN,じあん
56
+ 1024,万寿,MANJU,まんじゅ
57
+ 1028,長元,CHOGEN,ちょうげん
58
+ 1037,長暦,CHORYAKU,ちょうりゃく
59
+ 1040,長久,CHOKYU,ちょうきゅう
60
+ 1044,寛徳,KANTOKU,かんとく
61
+ 1046,永承,EISHO,えいしょう
62
+ 1053,天喜,TENGI,てんぎ
63
+ 1058,康平,KOHEI,こうへい
64
+ 1065,治暦,JIRYAKU,じりゃく
65
+ 1069,延久,ENKYU,えんきゅう
66
+ 1074,承保,SHOHO,しょうほう
67
+ 1077,承暦,SHORYAKU,しょうりゃく
68
+ 1081,永保,EIHO,えいほ
69
+ 1084,応徳,OTOKU,おうとく
70
+ 1087,寛治,KANJI,かんじ
71
+ 1094,嘉保,KAHO,かほう
72
+ 1096,永長,EICHO,えいちょう
73
+ 1097,承徳,SHOTOKU,しょうとく
74
+ 1099,康和,KOWA,こうわ
75
+ 1104,長治,CHOJI,ちょうじ
76
+ 1106,嘉承,KAJO,かじょう
77
+ 1108,天仁,TENNIN,てんにん
78
+ 1110,天永,TENEI,てんえい
79
+ 1113,永久,EIKYU,えいきゅう
80
+ 1118,元永,GENEI,げんえい
81
+ 1120,保安,HOAN,ほうあん
82
+ 1124,天治,TENJI,てんじ
83
+ 1126,大治,TAIJI,たいじ
84
+ 1131,天承,TENSHO,てんしょう
85
+ 1132,長承,CHOSHO,ちょうしょう
86
+ 1135,保延,HOEN,ほうえん
87
+ 1141,永治,EIJI,えいじ
88
+ 1142,康治,KOJI,こうじ
89
+ 1144,天養,TENYO,てんよう
90
+ 1145,久安,KYUAN,きゅうあん
91
+ 1151,仁平,NIMPYO,にんぴょう
92
+ 1154,久寿,KYUJU,きゅうじゅ
93
+ 1156,保元,HOGEN,ほうげん
94
+ 1159,平治,HEIJI,へいじ
95
+ 1160,永暦,EIRYAKU,えいりゃく
96
+ 1161,応保,OHO,おうほ
97
+ 1163,長寛,CHOKAN,ちょうかん
98
+ 1165,永万,EIMAN,えいまん
99
+ 1166,仁安,NINAN,にんあん
100
+ 1169,嘉応,KAO,かおう
101
+ 1171,承安,JOAN,じょうあん
102
+ 1175,安元,ANGEN,あんげん
103
+ 1177,治承,JISHO,じしょう
104
+ 1181,養和,YOWA,ようわ
105
+ 1182,寿永,JUEI,じゅえい
106
+ 1184,元暦,GENRYAKU,げんりゃく
107
+ 1185,文治,BUNJI,ぶんじ
108
+ 1190,建久,KENKYU,けんきゅう
109
+ 1199,正治,SHOJI,しょうじ
110
+ 1201,建仁,KENNIN,けんにん
111
+ 1204,元久,GENKYU,げんきゅう
112
+ 1206,建永,KENEI,けんえい
113
+ 1207,承元,SHOGEN,しょうげん
114
+ 1211,建暦,KENRYAKU,けんりゃく
115
+ 1213,健保,KEMPO,けんぽ
116
+ 1219,承久,JOKYU,じょうきゅう
117
+ 1222,貞応,JOO,じょうおう
118
+ 1224,元仁,GENNIN,げんにん
119
+ 1225,嘉禄,KAROKU,かろく
120
+ 1227,安貞,ANTEI,あんてい
121
+ 1229,寛喜,KANGI,かんぎ
122
+ 1232,貞永,JOEI,じょうえい
123
+ 1233,天福,TEMPUKU,てんぷく
124
+ 1234,文暦,BUNRYAKU,ぶんりゃく
125
+ 1235,嘉禎,KATEI,かてい
126
+ 1238,暦仁,RYAKUNIN,りゃくにん
127
+ 1239,延応,ENNO,えんのう
128
+ 1240,仁治,NINJI,にんじ
129
+ 1243,寛元,KANGEN,かんげん
130
+ 1247,宝治,HOJI,ほうじ
131
+ 1249,建長,KENCHO,けんちょう
132
+ 1256,康元,KOGEN,こうげん
133
+ 1257,正嘉,SHOKA,しょうか
134
+ 1259,正元,SHOGEN,しょうげん
135
+ 1260,文応,BUNO,ぶんおう
136
+ 1261,弘長,KOCHO,こうちょう
137
+ 1264,文永,BUNEI,ぶんえい
138
+ 1275,建治,KENJI,けんじ
139
+ 1278,弘安,KOAN,こうあん
140
+ 1288,正応,SHOO,しょうおう
141
+ 1293,永仁,EININ,えいにん
142
+ 1299,正安,SHOAN,しょうあん
143
+ 1302,乾元,KENGEN,けんげん
144
+ 1303,嘉元,KAGEN,かげん
145
+ 1306,徳治,TOKUJI,とくじ
146
+ 1308,延慶,ENKYO,えんきょう
147
+ 1311,応長,OCHO,おうちょう
148
+ 1312,正和,SHOWA,しょうわ
149
+ 1317,文保,BUMPO,ぶんぽ
150
+ 1319,元応,GENO,げんおう
151
+ 1321,元亨,GENKO,げんこう
152
+ 1324,正中,SHOCHU,しょうちゅう
153
+ 1326,嘉暦,KARYAKU,かりゃく
154
+ 1329,元徳,GENTOKU,げんとく
155
+ 1331,元弘,GENKO,げんこう
156
+ 1329,元徳,GENTOKU,げんとく
157
+ 1332,正慶,SHOKYO,しょうきょう
158
+ 1334,建武,KEMMU,けんむ
159
+ 1338,暦応,RYAKUO,りゃくおう
160
+ 1342,康永,KOEI,こうえい
161
+ 1345,貞和,JOWA,じょうわ
162
+ 1350,観応,KANNO,かんのう
163
+ 1352,文和,BUNNA,ぶんな
164
+ 1356,延文,EMBUN,えんぶん
165
+ 1361,康安,KOAN,こうあん
166
+ 1362,貞治,JOJI,じょうじ
167
+ 1368,応安,OAN,おうあん
168
+ 1375,永和,EIWA,えいわ
169
+ 1379,康暦,KORYAKU,こうりゃく
170
+ 1381,永徳,EITOKU,えいとく
171
+ 1384,至徳,SHITOKU,しとく
172
+ 1387,嘉慶,KAKYO,かきょう
173
+ 1389,康応,KOO,こうおう
174
+ 1390,明徳,MEITOKU,めいとく
175
+ 1428,応永,OEI,おうえい
176
+ 1429,永享,EIKYO,えいきょう
177
+ 1441,嘉吉,KAKITSU,かきつ
178
+ 1444,文安,BUNAN,ぶんあん
179
+ 1449,宝徳,HOTOKU,ほうとく
180
+ 1455,康正,KOSHO,こうしょう
181
+ 1457,長禄,CHOROKU,ちょうろく
182
+ 1460,寛正,KANSHO,かんしょう
183
+ 1466,文正,BUNSHO,ぶんしょう
184
+ 1467,応仁,ONIN,おうにん
185
+ 1469,文明,BUMMEI,ぶんめい
186
+ 1487,長享,CHOKYO,ちょうきょう
187
+ 1489,延徳,ENTOKU,えんとく
188
+ 1492,明応,MEIO,めいおう
189
+ 1501,文亀,BUNKI,ぶんき
190
+ 1504,永正,EISHO,えいしょう
191
+ 1521,大永,TAIEI,たいえい
192
+ 1528,享禄,KYOROKU,きょうろく
193
+ 1532,天文,TEMBUN,てんぶん
194
+ 1555,弘治,KOJI,こうじ
195
+ 1558,永禄,EIROKU,えいろく
196
+ 1570,元亀,GENKI,げんき
197
+ 1573,天正,TENSHO,てんしょう
198
+ 1592,文禄,BUNROKU,ぶんろく
199
+ 1596,慶長,KEICHO,けいちょう
200
+ 1615,元和,GENNA,げんな
201
+ 1624,寛永,KANEI,かんえい
202
+ 1644,正保,SHOHO,しょうほ
203
+ 1648,慶安,KEIAN,けいあん
204
+ 1652,承応,JOO,じょうおう
205
+ 1655,明暦,MEIREKI,めいれき
206
+ 1658,万治,MANJI,まんじ
207
+ 1661,寛文,KAMBUN,かんぶん
208
+ 1673,延宝,EMPO,えんぽう
209
+ 1681,天和,TENNA,てんな
210
+ 1684,貞享,JOKYO,じょうきょう
211
+ 1688,元禄,GENROKU,げんろく
212
+ 1704,宝永,HOEI,ほうえい
213
+ 1711,正徳,SHOTOKU,しょうとく
214
+ 1816,享保,KYOHO,きょうほう
215
+ 1736,元文,GEMBUN,げんぶん
216
+ 1741,寛保,KAMPO,かんぽう
217
+ 1744,延享,ENKYO,えんきょう
218
+ 1748,寛延,KANEN,かんえん
219
+ 1751,宝暦,HOREKI,ほうれき
220
+ 1764,明和,MEIWA,めいわ
221
+ 1772,安永,ANEI,あんえい
222
+ 1781,天明,TEMMEI,てんめい
223
+ 1789,寛政,KANSEI,かんせい
224
+ 1801,享和,KYOWA,きょうわ
225
+ 1804,文化,BUNKA,ぶんか
226
+ 1818,文政,BUNSEI,ぶんせい
227
+ 1830,天保,TEMPO,てんぽう
228
+ 1844,弘化,KOKA,こうか
229
+ 1848,嘉永,KAEI,かえい
230
+ 1854,安政,ANSEI,あんせい
231
+ 1860,万延,MANEN,まんえん
232
+ 1861,文久,BUNKYU,ぶんきゅう
233
+ 1864,元治,GENJI,げんじ
234
+ 1865,慶応,KEIO,けいおう
235
+ 1868,明治,MEIJI,めいじ
236
+ 1912,大正,TAISHO,たいしょう
237
+ 1926,昭和,SHOWA,しょうわ
238
+ 1989,平成,HEISEI,へいせい
239
+ 2019,令和,REIWA,れいわ
@@ -1,59 +1,59 @@
1
- require "gengo_search/version"
2
- require 'csv'
3
-
4
- module GengoSearch
5
- class Gengo
6
- attr_reader :kanji, :romaji, :hiragana, :year
7
-
8
- ERAS = CSV.read(File.expand_path('../data/era_names.csv', __FILE__))
9
-
10
- def initialize(ad_year = nil)
11
- if ad_year.nil? || !(ad_year.is_a?(Integer)) || ad_year < 645 || ad_year > 9999 then
12
- raise ArgumentError, "Please set a correct number(645~9999)"
13
- else
14
- started_year_index = search(ad_year)
15
- setTargetEra(started_year_index, ad_year)
16
- end
17
- end
18
-
19
- #Using Binary Search
20
- def search(target = 0)
21
-
22
- head = 0
23
- tail = ERAS.count - 1
24
-
25
- if ERAS[tail][0].to_i <= target then
26
- return tail
27
- else
28
- while head <= tail
29
-
30
- center = (head + tail) / 2
31
-
32
- if ERAS[center][0].to_i <= target && target < ERAS[center + 1][0].to_i then
33
- return center
34
- elsif ERAS[center][0].to_i < target
35
- head = center + 1
36
- else
37
- tail = center - 1
38
- end
39
- end
40
- end
41
-
42
-
43
- end
44
-
45
- def setTargetEra(started_year_index = 0, ad_year = 0)
46
- year = ad_year - ERAS[started_year_index][0].to_i + 1
47
- if year == 1 then
48
- @kanji = "#{ERAS[started_year_index][1]} 元年"
49
- @hiragana = "#{ERAS[started_year_index][3]} がんねん"
50
- @romaji = "#{ERAS[started_year_index][2]} GANNEN"
51
- else
52
- @kanji = "#{ERAS[started_year_index][1]} #{year}年"
53
- @romaji = "#{ERAS[started_year_index][2]} #{year}NEN"
54
- @hiragana = "#{ERAS[started_year_index][3]} #{year}ねん"
55
- end
56
- end
57
-
58
- end
59
- end
1
+ require "gengo_search/version"
2
+ require 'csv'
3
+
4
+ module GengoSearch
5
+ class Gengo
6
+ attr_reader :kanji, :romaji, :hiragana, :year
7
+
8
+ ERAS = CSV.read(File.expand_path('../data/era_names.csv', __FILE__))
9
+
10
+ def initialize(ad_year = nil)
11
+ if ad_year.nil? || !(ad_year.is_a?(Integer)) || ad_year < 645 || ad_year > 9999 then
12
+ raise ArgumentError, "Please set a correct number(645~9999)"
13
+ else
14
+ started_year_index = search(ad_year)
15
+ setTargetEra(started_year_index, ad_year)
16
+ end
17
+ end
18
+
19
+ #Using Binary Search
20
+ def search(target = 0)
21
+
22
+ head = 0
23
+ tail = ERAS.count - 1
24
+
25
+ if ERAS[tail][0].to_i <= target then
26
+ return tail
27
+ else
28
+ while head <= tail
29
+
30
+ center = (head + tail) / 2
31
+
32
+ if ERAS[center][0].to_i <= target && target < ERAS[center + 1][0].to_i then
33
+ return center
34
+ elsif ERAS[center][0].to_i < target
35
+ head = center + 1
36
+ else
37
+ tail = center - 1
38
+ end
39
+ end
40
+ end
41
+
42
+
43
+ end
44
+
45
+ def setTargetEra(started_year_index = 0, ad_year = 0)
46
+ year = ad_year - ERAS[started_year_index][0].to_i + 1
47
+ if year == 1 then
48
+ @kanji = "#{ERAS[started_year_index][1]} 元年"
49
+ @hiragana = "#{ERAS[started_year_index][3]} がんねん"
50
+ @romaji = "#{ERAS[started_year_index][2]} GANNEN"
51
+ else
52
+ @kanji = "#{ERAS[started_year_index][1]} #{year}年"
53
+ @romaji = "#{ERAS[started_year_index][2]} #{year}NEN"
54
+ @hiragana = "#{ERAS[started_year_index][3]} #{year}ねん"
55
+ end
56
+ end
57
+
58
+ end
59
+ end
@@ -1,3 +1,3 @@
1
- module GengoSearch
2
- VERSION = "0.1.1"
3
- end
1
+ module GengoSearch
2
+ VERSION = "0.1.2"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gengo_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - shoyu777
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-20 00:00:00.000000000 Z
11
+ date: 2019-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler