kgl 0.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 +7 -0
- data/.gitattributes +2 -0
- data/.gitignore +9 -0
- data/CHANGELOG.md +4 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/kgl.gemspec +35 -0
- data/lib/kgl.rb +12 -0
- data/lib/kgl/kmath.rb +42 -0
- data/lib/kgl/suu.rb +285 -0
- data/lib/kgl/version.rb +3 -0
- metadata +103 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a79f55cfe832aa5201063e4889e123bf901f6c32b3f2614b73570785d0a622a4
|
|
4
|
+
data.tar.gz: 04d4cd0f6c9aeb34c8c121ade5d35a0877749c96894f3525deabc8817eb14c94
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d7ae7d157744d0cbb6fb68c2012d78c30a377047981b5ceb6b080533b15144a13fa359d39c5a954f2a805e77c9f223554badd056db1cdcc734abeb30f0a605c9
|
|
7
|
+
data.tar.gz: 78760ddeee6dd993e5707b46072550f023dceb661f430072f7976db205a555ebe0c3edbd1f4e24c0bd881a1ad9cdd841db59d32cd730bcf002b1e5304edac9f7
|
data/.gitattributes
ADDED
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +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 cycloawaodorin+github@gmail.com. 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
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 cycloawaodorin
|
|
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
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# KGL
|
|
2
|
+
|
|
3
|
+
A ruby gem for personal use.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
$ gem install kgl
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
### `Integer#name(lang)`
|
|
11
|
+
Returns the natural number expression for `self` in specific natural language. Available languages are the follows.
|
|
12
|
+
|
|
13
|
+
|`lang`|Language|
|
|
14
|
+
|:-|:-|
|
|
15
|
+
|`"j"`|Japanese|
|
|
16
|
+
|`"a"`|American English (a billion is `10**9`)|
|
|
17
|
+
|`"b"`|British English (a billion is `10**12`)|
|
|
18
|
+
|
|
19
|
+
### `Math.#ln(anti_logarithm)`
|
|
20
|
+
An alias of original `Math.#log`. It returns the natural logarithm of `anti_logarithm`.
|
|
21
|
+
|
|
22
|
+
### `Math.#log(base, anti_logarithm=base.tap{base=Math::E})`
|
|
23
|
+
Returns the logarithm of `anti_logarithm` to base `base`.
|
|
24
|
+
|
|
25
|
+
### `Math.#lg(anti_logarithm)
|
|
26
|
+
Returns the logarithm of `anti_logarithm` to base 2.
|
|
27
|
+
|
|
28
|
+
### `Float#to_r`, `String#to_r`
|
|
29
|
+
Returns `Rational` value of `self`.
|
|
30
|
+
|
|
31
|
+
### `Integer#to_msm(fps=60)`
|
|
32
|
+
Returns `"[minutes]:[seconds].[milliseconds]"` which corresponds to `self` frames.
|
|
33
|
+
The submilliseconds will be rounded. `fps` is frames per second.
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
38
|
+
|
|
39
|
+
## Code of Conduct
|
|
40
|
+
|
|
41
|
+
Everyone interacting in the KGL project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/cycloawaodorin/kgl/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "kgl"
|
|
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
ADDED
data/kgl.gemspec
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require "kgl/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "kgl"
|
|
7
|
+
spec.version = Kgl::VERSION
|
|
8
|
+
spec.authors = ["KAZOON"]
|
|
9
|
+
spec.email = ["cycloawaodorin+gem@gmail.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = %q{A gem for personal use.}
|
|
12
|
+
#spec.description = %q{TODO: Write a longer description or delete this line.}
|
|
13
|
+
spec.homepage = "https://github.com/cycloawaodorin/"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
#spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
|
17
|
+
|
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/cycloawaodorin/kgl"
|
|
20
|
+
spec.metadata["changelog_uri"] = "https://github.com/cycloawaodorin/kgl/blob/master/CHANGELOG.md"
|
|
21
|
+
|
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
24
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
+
end
|
|
27
|
+
spec.bindir = "exe"
|
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
29
|
+
spec.require_paths = ["lib"]
|
|
30
|
+
|
|
31
|
+
spec.add_development_dependency "bundler", ">= 2.0"
|
|
32
|
+
spec.add_development_dependency "rake", ">= 10.0"
|
|
33
|
+
spec.add_development_dependency "pry", ">= 0.12.2"
|
|
34
|
+
spec.required_ruby_version = '>= 2.6.0'
|
|
35
|
+
end
|
data/lib/kgl.rb
ADDED
data/lib/kgl/kmath.rb
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Math
|
|
2
|
+
alias ln log
|
|
3
|
+
module_function
|
|
4
|
+
def log(base, anti_logarithm=base.tap{base=nil})
|
|
5
|
+
if base.nil?
|
|
6
|
+
ln(angi_logarithm)
|
|
7
|
+
else
|
|
8
|
+
ln(anti_logarithm).quo(ln(base))
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
def lg(anti_logarithm)
|
|
12
|
+
log(2, anti_logarithm)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class Float
|
|
17
|
+
def to_r
|
|
18
|
+
str=self.to_s
|
|
19
|
+
(decimal,power)=str.split(/e/)
|
|
20
|
+
(integer,decimal)=decimal.split(/\./)
|
|
21
|
+
length=decimal.length
|
|
22
|
+
numerator=integer.to_i*10**length+decimal.to_i
|
|
23
|
+
denominator=10**length
|
|
24
|
+
power=power.to_i
|
|
25
|
+
if power>0
|
|
26
|
+
numerator*=10**power
|
|
27
|
+
else
|
|
28
|
+
denominator*=10**(-power)
|
|
29
|
+
end
|
|
30
|
+
return Rational(numerator,denominator)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
class String
|
|
34
|
+
def to_r
|
|
35
|
+
(numerator,denominator)=self.split(/\//)
|
|
36
|
+
if self.match(/\.|e/)
|
|
37
|
+
return numerator.to_f.to_r/denominator.to_f.to_r
|
|
38
|
+
else
|
|
39
|
+
return Rational(numerator.to_i,denominator.to_i)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
data/lib/kgl/suu.rb
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# 整数を日本語等で表した時の文字列(self<0ならnil)を返すメソッド Integer#express を提供する。
|
|
2
|
+
# 補助的に使用する定数や関数は Integer::SuuConstantsAndSubFunctions モジュールで定義されている。
|
|
3
|
+
# Integer クラスでこのモジュールを include している。
|
|
4
|
+
# 第一引数 lang には文字列を与える。
|
|
5
|
+
# lang の先頭の文字(大文字小文字問わず)でどの言語に変換するかを判断する。
|
|
6
|
+
# 以下,変換可能な言語とその補足説明を記す。
|
|
7
|
+
# d: 十進位取り
|
|
8
|
+
# ただの Integer#to_s 。
|
|
9
|
+
# f: 浮動小数点数
|
|
10
|
+
# 第二引数 acc を使用する。
|
|
11
|
+
# ほぼ "%1.#{acc-1}e" % self.to_f と同じだが,Floatの範囲外の大きな整数でも使える。
|
|
12
|
+
# acc が1未満の場合は ArgumentError を発生。
|
|
13
|
+
# j: 日本語
|
|
14
|
+
# 一般に用いられる万進法による中数である。極以上を万万進とすることや,無量大数を分けることはしない。
|
|
15
|
+
# 千~においては省略しないこともままあるが,ここでは十,百,千~の位が1のとき一の文字を省略する。
|
|
16
|
+
# 千無量大数の十倍以上の数は表わせないので RangeError を発生。
|
|
17
|
+
# 参考:無量大数の彼方へ(http://www.sf.airnet.ne.jp/ts/language/largenumber.html)
|
|
18
|
+
# m: 中数(万万進)。
|
|
19
|
+
# 日本語のように十,百,千~の位が1のとき一の文字を省略するのか定かでないが,ここでは省略しないことにした。
|
|
20
|
+
# 一千万無量大数の十倍以上の数は表わせないので RangeError を発生。
|
|
21
|
+
# 参考:無量大数の彼方へ(http://www.sf.airnet.ne.jp/ts/language/largenumber.html)
|
|
22
|
+
# a: 英語(アメリカ式)
|
|
23
|
+
# b: 英語(ヨーロッパ式)
|
|
24
|
+
# 参考:Name of a Number(http://isthe.com/chongo/tech/math/number/number.html)
|
|
25
|
+
class Integer
|
|
26
|
+
module SuuConstantsAndSubFunctions
|
|
27
|
+
Ichi = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'].freeze
|
|
28
|
+
Juu = ['', '十', '百', '千'].freeze
|
|
29
|
+
Man = ['', '万', '億', '兆', '京', '垓', '杼', '穣', '溝', '澗', '正', '載', '極',
|
|
30
|
+
'恒河沙', '阿僧祇', '那由他', '不可思議', '無量大数'].freeze
|
|
31
|
+
Mi = ['', 'm', 'b', 'tr', 'quadr', 'quint', 'sext', 'sept', 'oct', 'non'].freeze
|
|
32
|
+
Un = ['', 'un', 'do', 'tre', 'quattuor', 'quin', 'sex', 'septen', 'octo', 'novem'].freeze
|
|
33
|
+
Gin = ['', 'dec', 'vigin', 'trigin', 'quadragin', 'quinquagin',
|
|
34
|
+
'sexagin', 'septuagin', 'octogin', 'nonagin'].freeze
|
|
35
|
+
Cen = ['', 'cen', 'ducen', 'trecen', 'quadringen', 'quingen',
|
|
36
|
+
'sescen', 'septingen', 'octingen', 'nongen'].freeze
|
|
37
|
+
One = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine','ten', 'eleven',
|
|
38
|
+
'twelve', 'thirteen', 'forteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'].freeze
|
|
39
|
+
Ten = ['', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'].freeze
|
|
40
|
+
module_function
|
|
41
|
+
def us(p)
|
|
42
|
+
if p == -1
|
|
43
|
+
''
|
|
44
|
+
elsif p == 0
|
|
45
|
+
'thousand'
|
|
46
|
+
elsif p < 1000
|
|
47
|
+
ret = ''
|
|
48
|
+
if p < 10
|
|
49
|
+
ret = Mi[p] + 'illion' + ret
|
|
50
|
+
else
|
|
51
|
+
z = p.to_s
|
|
52
|
+
z = '0' + z if z.length == 2
|
|
53
|
+
if z[1..2].to_i < 10
|
|
54
|
+
ret = Un[z[2..2].to_i] + 'tillion' + ret
|
|
55
|
+
elsif z[1..2].to_i < 20
|
|
56
|
+
ret = Un[z[2..2].to_i] + 'decillion' + ret
|
|
57
|
+
else
|
|
58
|
+
ret = Un[z[2..2].to_i] + Gin[z[1..1].to_i] + 'tillion' + ret
|
|
59
|
+
end
|
|
60
|
+
ret = Cen[z[0..0].to_i] + ret
|
|
61
|
+
end
|
|
62
|
+
ret
|
|
63
|
+
else
|
|
64
|
+
c = p.to_s
|
|
65
|
+
ret = ''
|
|
66
|
+
x = c[-3, 3]
|
|
67
|
+
if x[1..2].to_i < 10
|
|
68
|
+
ret = Un[x[2..2].to_i] + 'tillion' + ret
|
|
69
|
+
elsif x[1..2].to_i < 20
|
|
70
|
+
ret = Un[x[2..2].to_i] + 'decillion' + ret
|
|
71
|
+
else
|
|
72
|
+
ret = Un[x[2..2].to_i] + Gin[x[1..1].to_i] + 'tillion' + ret
|
|
73
|
+
end
|
|
74
|
+
ret = Cen[x[0..0].to_i] + ret
|
|
75
|
+
c = c[0..-4]
|
|
76
|
+
m = 1
|
|
77
|
+
while x = c[-3, 3]
|
|
78
|
+
ret = 'millia'*m + ret
|
|
79
|
+
ret = Un[x[2..2].to_i] + (x[1..2].to_i<10 ? '' : Gin[x[1..1].to_i]) + ret
|
|
80
|
+
ret = Cen[x[0..0].to_i] + ret
|
|
81
|
+
c = c[0..-4]
|
|
82
|
+
m += 1
|
|
83
|
+
end
|
|
84
|
+
if c != ''
|
|
85
|
+
ret = 'millia'*m + ret
|
|
86
|
+
if c.length == 1
|
|
87
|
+
c = '00' + c
|
|
88
|
+
elsif c.length == 2
|
|
89
|
+
c = '0' + c
|
|
90
|
+
end
|
|
91
|
+
ret = Un[c[2..2].to_i] + (c[1..2].to_i<10 ? '' : Gin[c[1..1].to_i]) + ret if c != '001'
|
|
92
|
+
ret = Cen[c[0..0].to_i] + ret
|
|
93
|
+
end
|
|
94
|
+
ret
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
def gb(p)
|
|
98
|
+
c = p.div(2)
|
|
99
|
+
suf = (p%2==0 ? 'on' : 'ard')
|
|
100
|
+
if c == 0
|
|
101
|
+
p%2 == 0 ? '' : 'thousand'
|
|
102
|
+
elsif c < 1000
|
|
103
|
+
ret = ''
|
|
104
|
+
if c < 10
|
|
105
|
+
ret = Mi[c] + 'illi' + suf + ret
|
|
106
|
+
else
|
|
107
|
+
z = c.to_s
|
|
108
|
+
z = '0' + z if z.length == 2
|
|
109
|
+
if z[1..2].to_i<10
|
|
110
|
+
ret = Un[z[2..2].to_i] + 'tilli' + suf + ret
|
|
111
|
+
elsif z[1..2].to_i < 20
|
|
112
|
+
ret = Un[z[2..2].to_i] + 'decilli' + suf + ret
|
|
113
|
+
else
|
|
114
|
+
ret = Un[z[2..2].to_i] + Gin[z[1..1].to_i] + 'tilli' + suf + ret
|
|
115
|
+
end
|
|
116
|
+
ret = Cen[z[0..0].to_i] + ret
|
|
117
|
+
end
|
|
118
|
+
ret
|
|
119
|
+
else
|
|
120
|
+
c = c.to_s
|
|
121
|
+
ret = ''
|
|
122
|
+
x = c[-3, 3]
|
|
123
|
+
if x[1..2].to_i < 10
|
|
124
|
+
ret = Un[x[2..2].to_i] + 'tilli' + suf + ret
|
|
125
|
+
elsif x[1..2].to_i < 20
|
|
126
|
+
ret = Un[x[2..2].to_i] + 'decilli' + suf + ret
|
|
127
|
+
else
|
|
128
|
+
ret = Un[x[2..2].to_i] + Gin[x[1..1].to_i] + 'tilli' + suf + ret
|
|
129
|
+
end
|
|
130
|
+
ret = Cen[x[0..0].to_i] + ret
|
|
131
|
+
c = c[0..-4]
|
|
132
|
+
m = 1
|
|
133
|
+
while x = c[-3, 3]
|
|
134
|
+
ret = 'millia'*m + ret
|
|
135
|
+
ret = Un[x[2..2].to_i] + (x[1..2].to_i<10 ? '' : Gin[x[1..1].to_i]) + ret
|
|
136
|
+
ret = Cen[x[0..0].to_i] + ret
|
|
137
|
+
c = c[0..-4]
|
|
138
|
+
m += 1
|
|
139
|
+
end
|
|
140
|
+
if c != ''
|
|
141
|
+
ret = 'millia'*m + ret
|
|
142
|
+
if c.length == 1
|
|
143
|
+
c = '00' + c
|
|
144
|
+
elsif c.length == 2
|
|
145
|
+
c = '0' + c
|
|
146
|
+
end
|
|
147
|
+
ret = Un[c[2..2].to_i] + (c[1..2].to_i<10 ? '' : Gin[c[1..1].to_i]) + ret if c != '001'
|
|
148
|
+
ret = Cen[c[0..0].to_i] + ret
|
|
149
|
+
end
|
|
150
|
+
ret
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
include SuuConstantsAndSubFunctions
|
|
155
|
+
def express(lang='j', acc=7)
|
|
156
|
+
raise RangeError, 'negative integer' if self < 0
|
|
157
|
+
ni = self.to_s
|
|
158
|
+
ret = ''
|
|
159
|
+
case lang
|
|
160
|
+
when /^d/i #decimal
|
|
161
|
+
ret = ni
|
|
162
|
+
when /^f/i #float
|
|
163
|
+
raise ArgumentError, 'nonpositive float accuracy' if acc < 1
|
|
164
|
+
p = ni.length - 1
|
|
165
|
+
d = ni[0, acc+1]
|
|
166
|
+
while d.length < acc+1
|
|
167
|
+
d += '0'
|
|
168
|
+
end
|
|
169
|
+
d = d.to_i.div(10) + (((d.to_i%10)<5) ? 0 : 1)
|
|
170
|
+
if d >= 10**acc
|
|
171
|
+
d = d.div(10)
|
|
172
|
+
p += 1
|
|
173
|
+
end
|
|
174
|
+
d = d.to_s
|
|
175
|
+
d[1, 0] = '.'
|
|
176
|
+
ret = "#{d}e+#{p}"
|
|
177
|
+
when /^j/i #Japanese
|
|
178
|
+
return Ichi[0] if self==0
|
|
179
|
+
raise RangeError, 'too large for Japanese' if self >= 10**72
|
|
180
|
+
m = 0
|
|
181
|
+
while x = ni[-4, 4]
|
|
182
|
+
ret = Man[m] + ret if x != '0000'
|
|
183
|
+
0.upto(3){|i|
|
|
184
|
+
ret = ((i!=0 && x[3-i, 1]=='1') ? '' : Ichi[x[3-i, 1].to_i]) + Juu[i] + ret if x[3-i, 1] != '0'
|
|
185
|
+
}
|
|
186
|
+
ni = ni[0..-5]
|
|
187
|
+
m += 1
|
|
188
|
+
end
|
|
189
|
+
if ni != ''
|
|
190
|
+
ret = Man[m] + ret
|
|
191
|
+
x = ni.reverse.split(//)
|
|
192
|
+
ret = Ichi[x[0].to_i] + ret if x[0] != '0'
|
|
193
|
+
1.upto(2){|i|
|
|
194
|
+
ret = (x[i]=='1' ? '' : Ichi[x[i].to_i]) + Juu[i] + ret if x[i] && x[i] != '0'
|
|
195
|
+
}
|
|
196
|
+
end
|
|
197
|
+
when /^m/i #manmanshinhou
|
|
198
|
+
return Ichi[0] if self==0
|
|
199
|
+
raise RangeError, 'too large for manmanshinnhou' if self >= 10**136
|
|
200
|
+
m = 0
|
|
201
|
+
while x = ni[-8, 8]
|
|
202
|
+
ret = Man[m] + ret if x != '00000000'
|
|
203
|
+
0.upto(3){|i|
|
|
204
|
+
ret = Ichi[x[7-i, 1].to_i] + Juu[i] + ret if x[7-i, 1] != '0'
|
|
205
|
+
}
|
|
206
|
+
ret = Man[1] + ret if x != '0000'
|
|
207
|
+
0.upto(3){|i|
|
|
208
|
+
ret = Ichi[x[3-i, 1].to_i] + Juu[i] + ret if x[3-i, 1] != '0'
|
|
209
|
+
}
|
|
210
|
+
ni = ni[0..-9]
|
|
211
|
+
m = 1 if m == 0
|
|
212
|
+
m += 1
|
|
213
|
+
end
|
|
214
|
+
if ni != ''
|
|
215
|
+
ret = Man[m] + ret
|
|
216
|
+
x = ni.reverse.split(//)
|
|
217
|
+
0.upto(3){|i|
|
|
218
|
+
ret = Ichi[x[i].to_i] + Juu[i] + ret if x[i] && x[i] != '0'
|
|
219
|
+
}
|
|
220
|
+
ret = Man[1] + ret if x[4]
|
|
221
|
+
0.upto(2){|i|
|
|
222
|
+
ret = Ichi[x[4+i].to_i] + Juu[i] + ret if x[4+i] && x[4+i] != '0'
|
|
223
|
+
}
|
|
224
|
+
end
|
|
225
|
+
when /^a/i #American
|
|
226
|
+
return One[0] if self==0
|
|
227
|
+
m = -1
|
|
228
|
+
while x = ni[-3, 3]
|
|
229
|
+
ret = us(m) + ' ' + ret if x != '000'
|
|
230
|
+
if x[1..2].to_i < 20
|
|
231
|
+
ret = One[x[1..2].to_i] + ' ' + ret if x[1..2] != '00'
|
|
232
|
+
ret = One[x[0, 1].to_i] + ' hundred ' + ret if x[0, 1] != '0'
|
|
233
|
+
else
|
|
234
|
+
ret = One[x[2, 1].to_i] + ' ' + ret if x[2, 1] != '0'
|
|
235
|
+
ret = Ten[x[1, 1].to_i] + ' ' + ret if x[1, 1] != '0'
|
|
236
|
+
ret = One[x[0, 1].to_i] + ' hundred ' + ret if x[0, 1] != '0'
|
|
237
|
+
end
|
|
238
|
+
ni = ni[0..-4]
|
|
239
|
+
m += 1
|
|
240
|
+
end
|
|
241
|
+
if ni != ''
|
|
242
|
+
ret = us(m) + ' ' + ret
|
|
243
|
+
x = ni.reverse.split(//)
|
|
244
|
+
if x[1] == '1'
|
|
245
|
+
ret = One[(x[1]+x[0]).to_i] + ' ' + ret
|
|
246
|
+
else
|
|
247
|
+
ret = One[x[0].to_i] + ' ' + ret if x[0] != '0'
|
|
248
|
+
ret = Ten[x[1].to_i] + ' ' + ret if x[1] && x[1] != '0'
|
|
249
|
+
end
|
|
250
|
+
ret = One[x[2].to_i] + ' hundred ' + ret if x[2] && x[2] != '0'
|
|
251
|
+
end
|
|
252
|
+
when /^b/i #British
|
|
253
|
+
return One[0] if self==0
|
|
254
|
+
m = 0
|
|
255
|
+
while x = ni[-3, 3]
|
|
256
|
+
ret = gb(m) + ' ' + ret if x != '000'
|
|
257
|
+
if x[1..2].to_i < 20
|
|
258
|
+
ret = One[x[1..2].to_i] + ' ' + ret if x[1..2] != '00'
|
|
259
|
+
ret = One[x[0, 1].to_i] + ' hundred ' + ret if x[0, 1] != '0'
|
|
260
|
+
else
|
|
261
|
+
ret = One[x[2, 1].to_i] + ' ' + ret if x[2, 1] != '0'
|
|
262
|
+
ret = Ten[x[1, 1].to_i] + ' ' + ret if x[1, 1] != '0'
|
|
263
|
+
ret = One[x[0, 1].to_i] + ' hundred ' + ret if x[0, 1] != '0'
|
|
264
|
+
end
|
|
265
|
+
ni = ni[0..-4]
|
|
266
|
+
m += 1
|
|
267
|
+
end
|
|
268
|
+
if ni != ''
|
|
269
|
+
ret = gb(m) + ' ' + ret
|
|
270
|
+
x = ni.reverse.split(//)
|
|
271
|
+
if x[1] == '1'
|
|
272
|
+
ret = One[(x[1]+x[0]).to_i] + ' ' + ret
|
|
273
|
+
else
|
|
274
|
+
ret = One[x[0].to_i] + ' ' + ret if x[0] != '0'
|
|
275
|
+
ret = Ten[x[1].to_i] + ' ' + ret if x[1] && x[1] != '0'
|
|
276
|
+
end
|
|
277
|
+
ret = One[x[2].to_i] + ' hundred ' + ret if x[2] && x[2] != '0'
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
while ret[-1, 1] == ' '
|
|
281
|
+
ret = ret[0..-2]
|
|
282
|
+
end
|
|
283
|
+
ret
|
|
284
|
+
end
|
|
285
|
+
end
|
data/lib/kgl/version.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: kgl
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- KAZOON
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-08-30 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: pry
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 0.12.2
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 0.12.2
|
|
55
|
+
description:
|
|
56
|
+
email:
|
|
57
|
+
- cycloawaodorin+gem@gmail.com
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".gitattributes"
|
|
63
|
+
- ".gitignore"
|
|
64
|
+
- CHANGELOG.md
|
|
65
|
+
- CODE_OF_CONDUCT.md
|
|
66
|
+
- Gemfile
|
|
67
|
+
- LICENSE
|
|
68
|
+
- README.md
|
|
69
|
+
- Rakefile
|
|
70
|
+
- bin/console
|
|
71
|
+
- bin/setup
|
|
72
|
+
- kgl.gemspec
|
|
73
|
+
- lib/kgl.rb
|
|
74
|
+
- lib/kgl/kmath.rb
|
|
75
|
+
- lib/kgl/suu.rb
|
|
76
|
+
- lib/kgl/version.rb
|
|
77
|
+
homepage: https://github.com/cycloawaodorin/
|
|
78
|
+
licenses:
|
|
79
|
+
- MIT
|
|
80
|
+
metadata:
|
|
81
|
+
homepage_uri: https://github.com/cycloawaodorin/
|
|
82
|
+
source_code_uri: https://github.com/cycloawaodorin/kgl
|
|
83
|
+
changelog_uri: https://github.com/cycloawaodorin/kgl/blob/master/CHANGELOG.md
|
|
84
|
+
post_install_message:
|
|
85
|
+
rdoc_options: []
|
|
86
|
+
require_paths:
|
|
87
|
+
- lib
|
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
|
+
requirements:
|
|
90
|
+
- - ">="
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: 2.6.0
|
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
|
+
requirements:
|
|
95
|
+
- - ">="
|
|
96
|
+
- !ruby/object:Gem::Version
|
|
97
|
+
version: '0'
|
|
98
|
+
requirements: []
|
|
99
|
+
rubygems_version: 3.0.6
|
|
100
|
+
signing_key:
|
|
101
|
+
specification_version: 4
|
|
102
|
+
summary: A gem for personal use.
|
|
103
|
+
test_files: []
|