jisx0208 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/jisx0208/processor.rb +6 -6
- data/lib/jisx0208/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 236793cb86f7af7d0972bbebf88c34c280983d9314c5423c3584fa0bf97db545
|
4
|
+
data.tar.gz: 505358b58fc9f4392b83079b15c5f277a73fe023ace54aa2275f4d54a7483da6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eab224c8d024436be2ff6298e1ef30a4109e4f6e2879b8cf7c3eebb280edbb6444c1cf730649c0d7776d7adc8049970633bf42994c9e86c5e0912eda8f92e8fe
|
7
|
+
data.tar.gz: 21aa8b0d5309b6785c40dc819aaf284f1f4d4f043fc29008c0c6bbd89e2e813137c3daab7631fa4a8e1e64fba23bdc37b496dcc2bb98953a35943caf16ebb6b8
|
data/README.md
CHANGED
@@ -21,9 +21,10 @@ code.contains_seconde_level_kanji?("弌") # => true
|
|
21
21
|
code.contains_seconde_level_kanji?("亜") # => false
|
22
22
|
# same as (contains_first_level_kanji || contains_seconde_level_kanji)
|
23
23
|
code.contains_jisx0208_kanji?("亜弌") # => true
|
24
|
-
|
25
24
|
code.only_first_level_kanji?("回転寿司") # => true
|
26
25
|
code.only_second_level_kanji?("偃龠偕") # => true
|
27
|
-
#
|
26
|
+
# only (first level kanji + second level kanji)
|
28
27
|
code.only_jisx0208_kanji?("回転寿司偃龠偕") # => true
|
28
|
+
# hiragana, katakana, multi byte symbols + first level kanji
|
29
|
+
code.only_common_japanese_characters?("呪術廻戦は最高!") # => true
|
29
30
|
```
|
data/lib/jisx0208/processor.rb
CHANGED
@@ -18,6 +18,9 @@ module JISX0208
|
|
18
18
|
@first_level_ranges = collect_unicode_set(mappings, 0x3021, 0x4F53)
|
19
19
|
@second_level_ranges = collect_unicode_set(mappings, 0x5021, 0x7426)
|
20
20
|
@others_ranges = collect_unicode_set(mappings, 0x2120, 0x2840)
|
21
|
+
@common = @others_ranges + @first_level_ranges
|
22
|
+
@jisx0208_kanji = @first_level_ranges + @second_level_ranges
|
23
|
+
@jisx0208 = @first_level_ranges + @second_level_ranges + @others_ranges
|
21
24
|
end
|
22
25
|
|
23
26
|
def contains_first_level_kanji?(string)
|
@@ -47,19 +50,16 @@ module JISX0208
|
|
47
50
|
end
|
48
51
|
|
49
52
|
def only_jisx0208_kanji?(string)
|
50
|
-
|
51
|
-
string.each_char.all? { |char| jisx0208.include?(char.ord) }
|
53
|
+
string.each_char.all? { |char| @jisx0208_kanji.include?(char.ord) }
|
52
54
|
end
|
53
55
|
|
54
56
|
def only_jisx0208?(string)
|
55
|
-
|
56
|
-
string.each_char.all? { |char| jisx0208.include?(char.ord) }
|
57
|
+
string.each_char.all? { |char| @jisx0208.include?(char.ord) }
|
57
58
|
end
|
58
59
|
|
59
60
|
# hiragana, katakana, multi byte symbols, first level kanji
|
60
61
|
def only_common_japanese_characters?(string)
|
61
|
-
|
62
|
-
string.each_char.all? { |char| common.include?(char.ord) }
|
62
|
+
string.each_char.all? { |char| @common.include?(char.ord) }
|
63
63
|
end
|
64
64
|
|
65
65
|
private
|
data/lib/jisx0208/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jisx0208
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaiba
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Determines if a character is included in jisx0208 with JIS0208.TXT
|
14
14
|
email:
|