fake_io 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,36 @@
1
+ require 'fake_io'
2
+
3
+ class TestIO
4
+
5
+ include FakeIO
6
+
7
+ def initialize(chunks)
8
+ @index = 0
9
+ @blocks = chunks
10
+
11
+ super()
12
+ end
13
+
14
+ protected
15
+
16
+ def io_open
17
+ 3
18
+ end
19
+
20
+ def io_read
21
+ unless (block = @blocks[@index])
22
+ raise(EOFError,"end of stream")
23
+ end
24
+
25
+ @index += 1
26
+ return block
27
+ end
28
+
29
+ def io_write(data)
30
+ @blocks[@index] = data
31
+ @index += 1
32
+
33
+ return data.length
34
+ end
35
+
36
+ end