class DataMaker::Validators::ChineseCharacters
Constants
- CJK_CHARACTER_RANGES
Public Class Methods
new(characters)
click to toggle source
# File lib/data_maker/validators/chinese_characters.rb, line 12 def initialize(characters) @characters = characters end
Public Instance Methods
valid?()
click to toggle source
# File lib/data_maker/validators/chinese_characters.rb, line 16 def valid? valid_characters = true @characters.each_char do |character| hex_chinese = "%04x" % character[0].ord valid_characters = true unless within_cjk_range(hex_chinese) end end
Private Instance Methods
within_cjk_range(hex_string)
click to toggle source
# File lib/data_maker/validators/chinese_characters.rb, line 26 def within_cjk_range(hex_string) val = hex_string.hex CJK_CHARACTER_RANGES.each do |valid_range| return true if val >= valid_range[:min].hex && val <= valid_range[:max].hex end return false end