Class: CBETA::UnicodeService

Inherits:
Object
  • Object
show all
Defined in:
lib/cbeta/unicode_service.rb

Instance Method Summary collapse

Constructor Details

#initializeUnicodeService

Returns a new instance of UnicodeService.



2
3
4
# File 'lib/cbeta/unicode_service.rb', line 2

def initialize
  @u2 = Unihan2.new
end

Instance Method Details

#level1?(code) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
# File 'lib/cbeta/unicode_service.rb', line 6

def level1?(code)
  return false if code.nil?
  # Unicode 3.0 以內 在 mobile 可以正確顯示
  v = @u2.ver(code)
  raise "Unihan2.ver 回傳 nil, code: #{code}" if v.nil?
  v <= 3
end

#level2?(code) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/cbeta/unicode_service.rb', line 14

def level2?(code)
  return false if code.nil?
  # Unicode 10 以內 在 desktop 有字型可以顯示
  @u2.ver(code) <= 10
end