3 ch@
(String Character traits
) rot13
6 value
: (ch toLowercase as
: Integer
).
7 (value
>= 97) /\
(value
< 110)
8 ifTrue
: [value
: value
+ 13]
9 ifFalse
: [(value
> 109) /\
(value
<= 122)
10 ifTrue
: [value
: value
- 13]].
12 ifTrue
: [(value as
: String Character
) toUppercase
]
13 ifFalse
: [value as
: String Character
]
16 s@
(String traits
) rot13
18 result
: s newSameSize.
19 s doWithIndex
: [|
:each
:index |
20 result
at: index put
: each rot13
].
24 lobby define
: #Rot13Encoder &parents: {Encoder}.
27 c@
(Rot13Encoder traits
) convert
29 [c
in isAtEnd
] whileFalse
: [c out nextPut
: c
in next rot13
].
33 (Rot13Encoder newFrom
: Console reader to
: Console writer
) convert.