diff options
Diffstat (limited to 'woip/rb/article.rb')
-rw-r--r-- | woip/rb/article.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/woip/rb/article.rb b/woip/rb/article.rb new file mode 100644 index 0000000..eb44340 --- /dev/null +++ b/woip/rb/article.rb @@ -0,0 +1,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 |