author | Martin Kobetic |
Sun, 17 Nov 2013 00:23:18 -0500 | |
changeset 147 | bd6be28aa924 |
parent 109 | 9587e2df7029 |
permissions | -rw-r--r-- |
9 | 1 |
"{ Package: 'stx:goodies/xtreams/terminals' }" |
2 |
||
3 |
"{ NameSpace: Xtreams }" |
|
4 |
||
5 |
WriteStream subclass:#BlockClosureWriteStream |
|
6 |
instanceVariableNames:'contentsSpecies closeBlock' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
25
02e7c3b6f63c
added XtreamsPool to fix DefaultBufferSize; set proper category names
mkobetic
parents:
9
diff
changeset
|
9 |
category:'Xtreams-Terminals' |
9 | 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 |
|
109 | 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 |
|
9 | 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 |
||
109 | 75 |
version_HG |
76 |
||
77 |
^ '$Changeset: <not expanded> $' |
|
9 | 78 |
! ! |
109 | 79 |