Class: Thermal::Db::CjkEncoding
- Inherits:
-
Object
- Object
- Thermal::Db::CjkEncoding
- Defined in:
- lib/thermal/db/cjk_encoding.rb
Overview
Adds CJK character encoding lookup.
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#ruby ⇒ Object
readonly
Returns the value of attribute ruby.
Instance Method Summary collapse
- #char(u_char) ⇒ Object
- #char?(u_char) ⇒ Boolean
- #codepoint(u_codepoint) ⇒ Object
- #codepoint?(u_codepoint) ⇒ Boolean
-
#initialize(key, ruby) ⇒ CjkEncoding
constructor
A new instance of CjkEncoding.
Constructor Details
#initialize(key, ruby) ⇒ CjkEncoding
Returns a new instance of CjkEncoding.
9 10 11 12 |
# File 'lib/thermal/db/cjk_encoding.rb', line 9 def initialize(key, ruby) @key = key @ruby = ruby end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/thermal/db/cjk_encoding.rb', line 7 def key @key end |
#ruby ⇒ Object (readonly)
Returns the value of attribute ruby.
7 8 9 |
# File 'lib/thermal/db/cjk_encoding.rb', line 7 def ruby @ruby end |
Instance Method Details
#char(u_char) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/thermal/db/cjk_encoding.rb', line 24 def char(u_char) return if u_char.ord <= 127 char = u_char.encode(@ruby) char unless skip?(char) rescue EncodingError nil end |
#char?(u_char) ⇒ Boolean
33 34 35 |
# File 'lib/thermal/db/cjk_encoding.rb', line 33 def char?(u_char) !!char(u_char) end |
#codepoint(u_codepoint) ⇒ Object
14 15 16 17 18 |
# File 'lib/thermal/db/cjk_encoding.rb', line 14 def codepoint(u_codepoint) char(u_codepoint.chr('UTF-8')) rescue RangeError nil end |
#codepoint?(u_codepoint) ⇒ Boolean
20 21 22 |
# File 'lib/thermal/db/cjk_encoding.rb', line 20 def codepoint?(u_codepoint) !!codepoint(u_codepoint) end |