Class: TwitterCldr::Segmentation::CategoryTable

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_cldr/segmentation/category_table.rb

Constant Summary collapse

PACK_FMT_16 =
'NNn'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values) ⇒ CategoryTable

Returns a new instance of CategoryTable.



27
28
29
# File 'lib/twitter_cldr/segmentation/category_table.rb', line 27

def initialize(values)
  @values = values
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



25
26
27
# File 'lib/twitter_cldr/segmentation/category_table.rb', line 25

def values
  @values
end

Class Method Details

.load16(data) ⇒ Object



14
15
16
17
18
19
20
21
22
# 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

Instance Method Details

#dump16Object



35
36
37
38
39
40
41
42
43
# 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) ⇒ Object



31
32
33
# File 'lib/twitter_cldr/segmentation/category_table.rb', line 31

def get(codepoint)
  find(codepoint)[2]
end