blob: eb4434065fc4bb4d52456d1b93bb4195c89fb9cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# these are actually real ASCII codes
START_HEADING = 1.chr
START_TEXT = 2.chr
END_TEXT = 3.chr
class Article
attr_accessor :title
attr_accessor :body
def body
@body ||= ''
end
def write(str)
str.puts START_HEADING
str.puts title
str.puts body.size
str.puts START_TEXT
str.puts body
str.puts END_TEXT
str.flush
end
end
def stdin_gets
raise EOF if $stdin.closed?
line = $stdin.gets
raise EOF unless line
line
end
|