jisx0208 0.3.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: df31e4cd2133bcd6d29df8dc276a6d91416830a584562e481ec7bf467317a3da
4
- data.tar.gz: 403efbc30320410819b124682aa52cf74af5c39c5e8c9558514d9666b5ef0160
3
+ metadata.gz: 236793cb86f7af7d0972bbebf88c34c280983d9314c5423c3584fa0bf97db545
4
+ data.tar.gz: 505358b58fc9f4392b83079b15c5f277a73fe023ace54aa2275f4d54a7483da6
5
5
  SHA512:
6
- metadata.gz: 34088717a5e2e284b703d50d3846e9fd0c3e4e9e94067c508a9b713eddd560bee6105c9346682174f6c8e27a6360b6a027ffbb9ca0d7e212b9b7a5d582a19cb5
7
- data.tar.gz: 567da61871adffd160b74310a96da30ea3536f61beddeea494ec1370fda8d2cd5d6aba44cb02ccb04cfd0a2d67139e4a56dc9d7036c4caa0a5aec3136f81d719
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,13 +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) }
58
+ end
59
+
60
+ # hiragana, katakana, multi byte symbols, first level kanji
61
+ def only_common_japanese_characters?(string)
62
+ string.each_char.all? { |char| @common.include?(char.ord) }
57
63
  end
58
64
 
59
65
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jisx0208
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.1"
5
5
  end
data/lib/jisx0208.rb CHANGED
@@ -40,5 +40,9 @@ module JISX0208
40
40
  def only_jisx0208?(string)
41
41
  @processor.only_jisx0208?(string)
42
42
  end
43
+
44
+ def only_common_japanese_characters?(string)
45
+ @processor.only_common_japanese_characters?(string)
46
+ end
43
47
  end
44
48
  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.3.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: