Class: ICU::BreakIterator
- Inherits:
-
Object
- Object
- ICU::BreakIterator
- Includes:
- Enumerable
- Defined in:
- lib/ffi-icu/break_iterator.rb
Constant Summary collapse
- UBRK_DONE =
-1
Class Method Summary collapse
Instance Method Summary collapse
- #boundary?(offset) ⇒ Boolean
- #current ⇒ Object
- #each(&blk) ⇒ Object
- #first ⇒ Object
- #following(offset) ⇒ Object
-
#initialize(type, locale) ⇒ BreakIterator
constructor
A new instance of BreakIterator.
- #last ⇒ Object
- #next ⇒ Object
- #preceding(offset) ⇒ Object
- #previous ⇒ Object
- #text=(str) ⇒ Object
Constructor Details
#initialize(type, locale) ⇒ BreakIterator
Returns a new instance of BreakIterator.
13 14 15 16 17 |
# File 'lib/ffi-icu/break_iterator.rb', line 13 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 |
Class Method Details
Instance Method Details
#boundary?(offset) ⇒ Boolean
64 65 66 |
# File 'lib/ffi-icu/break_iterator.rb', line 64 def boundary?(offset) Lib.ubrk_isBoundary(@iterator, Integer(offset)) != 0 end |
#current ⇒ Object
60 61 62 |
# File 'lib/ffi-icu/break_iterator.rb', line 60 def current Lib.ubrk_current @iterator end |
#each(&blk) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ffi-icu/break_iterator.rb', line 25 def each(&blk) return to_enum(:each) unless block_given? int = first while int != UBRK_DONE yield int int = self.next end end |
#first ⇒ Object
44 45 46 |
# File 'lib/ffi-icu/break_iterator.rb', line 44 def first Lib.ubrk_first @iterator end |
#following(offset) ⇒ Object
56 57 58 |
# File 'lib/ffi-icu/break_iterator.rb', line 56 def following(offset) Lib.ubrk_following @iterator, Integer(offset) end |
#last ⇒ Object
48 49 50 |
# File 'lib/ffi-icu/break_iterator.rb', line 48 def last Lib.ubrk_last @iterator end |
#next ⇒ Object
36 37 38 |
# File 'lib/ffi-icu/break_iterator.rb', line 36 def next Lib.ubrk_next @iterator end |
#preceding(offset) ⇒ Object
52 53 54 |
# File 'lib/ffi-icu/break_iterator.rb', line 52 def preceding(offset) Lib.ubrk_preceding @iterator, Integer(offset) end |
#previous ⇒ Object
40 41 42 |
# File 'lib/ffi-icu/break_iterator.rb', line 40 def previous Lib.ubrk_next @iterator end |
#text=(str) ⇒ Object
19 20 21 22 23 |
# File 'lib/ffi-icu/break_iterator.rb', line 19 def text=(str) Lib.check_error { |err| Lib.ubrk_setText @iterator, UCharPointer.from_string(str), str.jlength, err } end |