#!/usr/local/bin/ruby require 'cgi' require 'erb' require 'drb/drb' $KCODE='euc' class BGColor def initialize @colors = ['#eeeeff', '#bbbbff'] @count = -1 end attr_accessor :colors def next_bgcolor @count += 1 @count = 0 if @colors.size <= @count "bgcolor='#{@colors[@count]}'" end alias :to_s :next_bgcolor end class ReminderWriter include ERB::Util def initialize(reminder) @reminder = reminder @erb = ERB.new(erb_src) @bg = BGColor.new end def erb_src < <% @reminder.to_a.each do |k, v| %> ><%= k %><%=h v %> <% end %> EOS end def to_html @erb.result(binding) end end def main DRb.start_service there = DRbObject.new_with_uri('druby://localhost:12345') writer = ReminderWriter.new(there) cgi = CGI.new('html3') cgi.out({"charset"=>"euc-jp"}) { cgi.html { cgi.head { cgi.title { 'Reminder' } } + cgi.body { writer.to_html } } } end main