Class: TwitterCldr::Collation::SortKeyBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_cldr/collation/sort_key_builder.rb

Overview

SortKeyBuilder builds a collation sort key from an array of collation elements.

Weights compression algorithms for every level are described in source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm

Constant Summary collapse

LEVEL_SEPARATOR =

separate levels in a sort key ‘01’ bytes

1
TERTIARY_LEVEL_MASK =

mask for removing case bits or continuation flag from a tertiary weight

0x3F
PRIMARY_BYTE_MIN =
0x3
PRIMARY_BYTE_MAX =
0xFF
MIN_NON_LATIN_PRIMARY =
0x5B
MAX_REGULAR_PRIMARY =
0x7A

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collation_elements) ⇒ SortKeyBuilder

Arguments:

collation_elements - an array of collation elements, represented as arrays of integer weights.


46
47
48
# File 'lib/twitter_cldr/collation/sort_key_builder.rb', line 46

def initialize(collation_elements)
  @collation_elements = collation_elements
end

Instance Attribute Details

#collation_elementsObject (readonly)

Returns the value of attribute collation_elements.



27
28
29
# File 'lib/twitter_cldr/collation/sort_key_builder.rb', line 27

def collation_elements
  @collation_elements
end

Class Method Details

.build(collation_elements) ⇒ Object

Returns a sort key as an array of bytes.

Arguments:

collation_elements - an array of collation elements, represented as arrays of integer weights.

An instance of the class is created only to prevent passing of @collation_elements and @bytes_array from one method into another while forming the sort key.



38
39
40
# File 'lib/twitter_cldr/collation/sort_key_builder.rb', line 38

def self.build(collation_elements)
  new(collation_elements).bytes_array
end

Instance Method Details

#bytes_arrayObject



50
51
52
# File 'lib/twitter_cldr/collation/sort_key_builder.rb', line 50

def bytes_array
  @bytes_array ||= build_bytes_array
end