class TwitterCldr::Segmentation::CategoryTable
Constants
- PACK_FMT_16
Attributes
values[R]
Public Class Methods
load16(data)
click to toggle source
# File lib/twitter_cldr/segmentation/category_table.rb, line 14 def load16(data) data = Base64.decode64(data) new( (0...data.size).step(10).map do |i| data[i...(i + 10)].unpack(PACK_FMT_16) end ) end
new(values)
click to toggle source
# File lib/twitter_cldr/segmentation/category_table.rb, line 27 def initialize(values) @values = values end
Public Instance Methods
dump16()
click to toggle source
# File lib/twitter_cldr/segmentation/category_table.rb, line 35 def dump16 data = ''.b.tap do |result| values.each do |vals| result << vals.pack(PACK_FMT_16) end end Base64.encode64(data) end
get(codepoint)
click to toggle source
# File lib/twitter_cldr/segmentation/category_table.rb, line 31 def get(codepoint) find(codepoint)[2] end
Private Instance Methods
cache()
click to toggle source
# File lib/twitter_cldr/segmentation/category_table.rb, line 55 def cache @cache ||= {} end
find(codepoint)
click to toggle source
# File lib/twitter_cldr/segmentation/category_table.rb, line 47 def find(codepoint) cache[codepoint] ||= values.bsearch do |entry| next -1 if codepoint < entry[0] next 1 if codepoint > entry[1] 0 end end