#! c:\ruby\bin\ruby.exe -Ks

String.class_eval do |string|
	def words
		self.split(//)
	end
	def fix_width(width, padding)
		(self.words.size > width) ? self : (padding * (width - self.words.size) + self)
	end
end

Fixnum.class_eval do |fixnum|
	alias :to_s_orig :to_s
	def to_s(base, width)
		binary = self.to_s_orig(base).fix_width(width, "0")
	end
end

class BinaryClock
	attr_accessor :now
	def initialize
		self.now = Time.now
	end
	def print
		output(self.now.hour.to_s(2, 5))
		output(self.now.min.to_s(2, 6))
	end
private
	def output(binary)
		puts binary.words.map { |f| f == "0" ? "□" : "■" }.join.fix_width(6, "　")
	end
end

BinaryClock.new.print
