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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81169ebbbff0fd9c19b339eda72d3b6b56a2cb7b2924e78e7692592e09b5d431
4
- data.tar.gz: 987e03026f974ce7ed2a880ab88eee6bfd528b43d69dfa3672af29569c1d1fcd
3
+ metadata.gz: 236793cb86f7af7d0972bbebf88c34c280983d9314c5423c3584fa0bf97db545
4
+ data.tar.gz: 505358b58fc9f4392b83079b15c5f277a73fe023ace54aa2275f4d54a7483da6
5
5
  SHA512:
6
- metadata.gz: f2a4199696e16c9c95e21d80d213c971c2dc726d6cd0930bd9b50c608238fccbbed3ca14b33413329e4b8b715f9314429516c4453fe4c1315cd056e767557a69
7
- data.tar.gz: 7b7846ccab60688360110c4ae3cb4afd9ffd0aefbbc1ec93f8c8b6328a05ffc1bfafb25b446f421e4bb8cc14694110aca0ce0a9e9539cca6c56891052a0850ed
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
- # same as (only_first_level_kanji || only_second_level_kanji)
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
  ```
@@ -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
- jisx0208 = @first_level_ranges + @second_level_ranges
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
- jisx0208 = @first_level_ranges + @second_level_ranges + @others_ranges
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
- common = @others_ranges + @first_level_ranges
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jisx0208
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
  end
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.0
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-20 00:00:00.000000000 Z
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: