Module: ICU::Collation

Defined in:
lib/ffi-icu/collation.rb

Defined Under Namespace

Classes: Collator

Class Method Summary collapse

Class Method Details

.available_localesObject



23
24
25
26
27
# File 'lib/ffi-icu/collation.rb', line 23

def self.available_locales
  (0...Lib.ucol_countAvailable).map do |idx|
    Lib.ucol_getAvailable idx
  end
end

.collate(locale, arr) ⇒ Object



4
5
6
# File 'lib/ffi-icu/collation.rb', line 4

def self.collate(locale, arr)
  Collator.new(locale).collate(arr)
end

.keywordsObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ffi-icu/collation.rb', line 8

def self.keywords
  enum_ptr = Lib.check_error { |error| Lib.ucol_getKeywords(error) }
  keywords = Lib.enum_ptr_to_array(enum_ptr)
  Lib.uenum_close enum_ptr

  hash = {}
  keywords.each do |keyword|
    enum_ptr = Lib.check_error { |error| Lib.ucol_getKeywordValues(keyword, error) }
    hash[keyword] = Lib.enum_ptr_to_array(enum_ptr)
    Lib.uenum_close(enum_ptr)
  end

  hash
end