hebrew 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hebrew.rb +21 -1
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41268cfa1a659bd6997ec10f67fbc3afd7d15f19
4
- data.tar.gz: f2d888c38878d69b06e7e9a057a58ffe175cf6af
3
+ metadata.gz: cdc23d69ac6c99a5089730a3980986821a750c9b
4
+ data.tar.gz: b436b60e4093251483a256677308733488108d95
5
5
  SHA512:
6
- metadata.gz: 686135b818c4d6867fe4a005ce09862705ed9b9eac5ed309e5bdbcae8bc1cd04764f8cd8f49feb1db6eccd4002abb4bde65b72f0db15cec9d53a9a91dc4a22b9
7
- data.tar.gz: 1241dc30e1b38a16cc2371d5d0e5c43441022b700a1c1569508e220fb69c6ef8d7d05af3bc965593ca19bce078c4159773532cfef32089bf8ba7820763321aab
6
+ metadata.gz: 4bebdf8bb10c1101b93811a36d2b21ac12c76068040e02073e35bd5570b084c802c8cc4ecf0bbf23bc5663bb00c8a3ecfe67b9db9d1b9adc2ca124534c88e5b8
7
+ data.tar.gz: c66e39755a562a5ac674deba0d678c5e115a74fbb16e12d2fdb299deeab608433168a5460d62f5e8e9401510e3f1735e97adf3bb7c89a7dc382e7717547e9b39
data/lib/hebrew.rb CHANGED
@@ -13,7 +13,8 @@ NIKKUD_UTF8 = [0x05b0, 0x05b1, 0x05b2, 0x05b3, 0x05b4, 0x05b5, 0x05b6, 0x05b7, 0
13
13
  FIANLS_CP1255 = ["\xea".force_encoding('windows-1255'), "\xed".force_encoding('windows-1255'), "\xef".force_encoding('windows-1255'), "\xf3".force_encoding('windows-1255'), "\xf5".force_encoding('windows-1255')]
14
14
 
15
15
  FINALS_UTF8 = []
16
-
16
+ HEB_UTF8_START = 1424
17
+ HEB_UTF8_END = 1535
17
18
  # extend String class
18
19
  class String
19
20
  # this will return the string, stripped of any Hebrew nikkud characters
@@ -43,6 +44,25 @@ class String
43
44
  }
44
45
  return target
45
46
  end
47
+ def any_hebrew?
48
+ case self.encoding
49
+ when Encoding::UTF_8
50
+ self.each_codepoint {|cp| return true if is_hebrew_codepoint_utf8(cp) }
51
+ return false
52
+ when Encoding::WINDOWS_1255 || Encoding::CP1255
53
+ self.each_codepoint {|cp| return true if is_hebrew_codepoint_cp1255(cp) }
54
+ return false
55
+ else
56
+ return false
57
+ end
58
+ end
59
+ def is_hebrew_codepoint_utf8(cp)
60
+ if cp >= HEB_UTF8_START && cp <= HEB_UTF8_END
61
+ return true
62
+ else
63
+ return false
64
+ end
65
+ end
46
66
  # TODO: add strip_nikkud!
47
67
  def is_nikkud(c)
48
68
  self.class.is_nikkud_by_encoding(c, self.encoding) # delegate to class method based on instance encoding
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hebrew
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asaf Bartov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-11 00:00:00.000000000 Z
11
+ date: 2014-02-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Some useful code to identify, transcode, and manipulate Hebrew text
14
14
  email: asaf.bartov@gmail.com
@@ -27,12 +27,12 @@ require_paths:
27
27
  - lib
28
28
  required_ruby_version: !ruby/object:Gem::Requirement
29
29
  requirements:
30
- - - '>='
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0'
33
33
  required_rubygems_version: !ruby/object:Gem::Requirement
34
34
  requirements:
35
- - - '>='
35
+ - - ">="
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  requirements: []