ffi-icu 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ffi-icu/break_iterator.rb +6 -6
- data/lib/ffi-icu/lib.rb +5 -0
- data/lib/ffi-icu/version.rb +1 -1
- data/spec/break_iterator_spec.rb +21 -0
- metadata +1 -1
@@ -47,20 +47,20 @@ module ICU
|
|
47
47
|
Lib.ubrk_last @iterator
|
48
48
|
end
|
49
49
|
|
50
|
-
def preceding
|
51
|
-
Lib.ubrk_preceding @iterator
|
50
|
+
def preceding(offset)
|
51
|
+
Lib.ubrk_preceding @iterator, Integer(offset)
|
52
52
|
end
|
53
53
|
|
54
|
-
def following
|
55
|
-
Lib.ubrk_following @iterator
|
54
|
+
def following(offset)
|
55
|
+
Lib.ubrk_following @iterator, Integer(offset)
|
56
56
|
end
|
57
57
|
|
58
58
|
def current
|
59
59
|
Lib.ubrk_current @iterator
|
60
60
|
end
|
61
61
|
|
62
|
-
def boundary?(
|
63
|
-
Lib.ubrk_isBoundary(@iterator, Integer(
|
62
|
+
def boundary?(offset)
|
63
|
+
Lib.ubrk_isBoundary(@iterator, Integer(offset)) != 0
|
64
64
|
end
|
65
65
|
|
66
66
|
end # BreakIterator
|
data/lib/ffi-icu/lib.rb
CHANGED
@@ -210,5 +210,10 @@ module ICU
|
|
210
210
|
attach_function :ubrk_previous, "ubrk_previous#{suffix}", [:pointer], :int32_t
|
211
211
|
attach_function :ubrk_first, "ubrk_first#{suffix}", [:pointer], :int32_t
|
212
212
|
attach_function :ubrk_last, "ubrk_last#{suffix}", [:pointer], :int32_t
|
213
|
+
|
214
|
+
attach_function :ubrk_preceding, "ubrk_preceding#{suffix}", [:pointer, :int32_t], :int32_t
|
215
|
+
attach_function :ubrk_following, "ubrk_following#{suffix}", [:pointer, :int32_t], :int32_t
|
216
|
+
attach_function :ubrk_isBoundary, "ubrk_isBoundary#{suffix}", [:pointer, :int32_t], :int32_t
|
217
|
+
|
213
218
|
end # Lib
|
214
219
|
end # ICU
|
data/lib/ffi-icu/version.rb
CHANGED
data/spec/break_iterator_spec.rb
CHANGED
@@ -24,5 +24,26 @@ module ICU
|
|
24
24
|
iterator.to_a.should == [0, 20, 65]
|
25
25
|
end
|
26
26
|
|
27
|
+
it "can navigate back and forward" do
|
28
|
+
iterator = BreakIterator.new :word, "en_US"
|
29
|
+
iterator.text = "Lorem ipsum dolor sit amet."
|
30
|
+
|
31
|
+
iterator.first.should == 0
|
32
|
+
iterator.next
|
33
|
+
iterator.current.should == 5
|
34
|
+
iterator.last.should == 27
|
35
|
+
end
|
36
|
+
|
37
|
+
it "fetches info about given offset" do
|
38
|
+
iterator = BreakIterator.new :word, "en_US"
|
39
|
+
iterator.text = "Lorem ipsum dolor sit amet."
|
40
|
+
|
41
|
+
iterator.following(3).should == 5
|
42
|
+
iterator.preceding(6).should == 5
|
43
|
+
|
44
|
+
iterator.should be_boundary(5)
|
45
|
+
iterator.should_not be_boundary(10)
|
46
|
+
end
|
47
|
+
|
27
48
|
end # BreakIterator
|
28
49
|
end # ICU
|