9
|
1 |
"{ Package: 'stx:goodies/xtreams/terminals' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Xtreams }"
|
|
4 |
|
|
5 |
WriteStream subclass:#BlockClosureWriteStream
|
|
6 |
instanceVariableNames:'contentsSpecies closeBlock'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'My Classes'
|
|
10 |
!
|
|
11 |
|
|
12 |
BlockClosureWriteStream comment:'Write stream on a single argument block, the block is evaluated for each element written with the element assigned as the argument of the evaluation.
|
|
13 |
{{{
|
|
14 |
"Transcript as an xtream"
|
|
15 |
[ :x | Transcript nextPut: x ] writing write: ''Hello World!!''
|
|
16 |
}}}
|
|
17 |
{{{
|
|
18 |
"/dev/null"
|
|
19 |
[ :x | ] writing write: ''Hello World!!''
|
|
20 |
}}}
|
|
21 |
|
|
22 |
Instance Variables
|
|
23 |
contentsSpecies <Class> species for collections of elements of this stream
|
|
24 |
closeBlock <BlockClosure> invoked in response to the #close message, allows customizing the close behavior
|
|
25 |
|
|
26 |
'
|
|
27 |
!
|
|
28 |
|
|
29 |
|
|
30 |
!BlockClosureWriteStream methodsFor:'accessing'!
|
|
31 |
|
|
32 |
write: anInteger from: aSequenceableCollection at: startIndex
|
|
33 |
| count |
|
|
34 |
count := 0.
|
|
35 |
[[count < anInteger] whileTrue:
|
|
36 |
[destination value: (aSequenceableCollection at: startIndex + count).
|
|
37 |
count := count + 1]]
|
|
38 |
on: Incomplete do: [(Incomplete on: aSequenceableCollection count: count at: startIndex) raise].
|
|
39 |
^anInteger
|
|
40 |
! !
|
|
41 |
|
|
42 |
!BlockClosureWriteStream methodsFor:'initialize-release'!
|
|
43 |
|
|
44 |
close
|
|
45 |
closeBlock cull: self
|
|
46 |
!
|
|
47 |
|
|
48 |
closeBlock
|
|
49 |
^closeBlock
|
|
50 |
!
|
|
51 |
|
|
52 |
closeBlock: aBlock
|
|
53 |
closeBlock := aBlock
|
|
54 |
!
|
|
55 |
|
|
56 |
contentsSpecies
|
|
57 |
^contentsSpecies
|
|
58 |
!
|
|
59 |
|
|
60 |
contentsSpecies: anObject
|
|
61 |
contentsSpecies := anObject
|
|
62 |
!
|
|
63 |
|
|
64 |
flush
|
|
65 |
!
|
|
66 |
|
|
67 |
on: aBlockClosure
|
|
68 |
super on: aBlockClosure.
|
|
69 |
contentsSpecies := Array.
|
|
70 |
closeBlock := []
|
|
71 |
! !
|
|
72 |
|
|
73 |
!BlockClosureWriteStream class methodsFor:'documentation'!
|
|
74 |
|
|
75 |
version_SVN
|
|
76 |
^ '$Id$'
|
|
77 |
! !
|