class ICU::BreakIterator
Constants
- DONE
Attributes
text[R]
Public Class Methods
available_locales()
click to toggle source
# File lib/ffi-icu/break_iterator.rb, line 9 def self.available_locales (0...Lib.ubrk_countAvailable).map do |idx| Lib.ubrk_getAvailable idx end end
new(type, locale)
click to toggle source
# File lib/ffi-icu/break_iterator.rb, line 15 def initialize(type, locale) ptr = Lib.check_error { |err| Lib.ubrk_open(type, locale, nil, 0, err) } @iterator = FFI::AutoPointer.new(ptr, Lib.method(:ubrk_close)) end
Public Instance Methods
boundary?(offset)
click to toggle source
# File lib/ffi-icu/break_iterator.rb, line 88 def boundary?(offset) Lib.ubrk_isBoundary(@iterator, Integer(offset)) != 0 end
current()
click to toggle source
# File lib/ffi-icu/break_iterator.rb, line 84 def current Lib.ubrk_current @iterator end
each() { |int| ... }
click to toggle source
# File lib/ffi-icu/break_iterator.rb, line 28 def each(&blk) return to_enum(:each) unless block_given? int = first while int != DONE yield int int = self.next end self end
each_substring() { |join| ... }
click to toggle source
# File lib/ffi-icu/break_iterator.rb, line 41 def each_substring(&blk) return to_enum(:each_substring) unless block_given? # each_char needed for 1.8, where String#[] works on bytes, not characters chars = text.each_char.to_a low = first while (high = self.next) != DONE yield chars[low...high].join low = high end self end
first()
click to toggle source
# File lib/ffi-icu/break_iterator.rb, line 68 def first Lib.ubrk_first @iterator end
following(offset)
click to toggle source
# File lib/ffi-icu/break_iterator.rb, line 80 def following(offset) Lib.ubrk_following @iterator, Integer(offset) end
last()
click to toggle source
# File lib/ffi-icu/break_iterator.rb, line 72 def last Lib.ubrk_last @iterator end
next()
click to toggle source
# File lib/ffi-icu/break_iterator.rb, line 60 def next Lib.ubrk_next @iterator end
preceding(offset)
click to toggle source
# File lib/ffi-icu/break_iterator.rb, line 76 def preceding(offset) Lib.ubrk_preceding @iterator, Integer(offset) end
previous()
click to toggle source
# File lib/ffi-icu/break_iterator.rb, line 64 def previous Lib.ubrk_next @iterator end
substrings()
click to toggle source
# File lib/ffi-icu/break_iterator.rb, line 56 def substrings each_substring.to_a end
text=(str)
click to toggle source
# File lib/ffi-icu/break_iterator.rb, line 20 def text=(str) @text = str Lib.check_error { |err| Lib.ubrk_setText @iterator, UCharPointer.from_string(str), str.jlength, err } end