=begin
= sample of WebUnit( digit.rb )
  Copyright(C) 2001 yuichi TAKAHASHI
  $Id: digit.rb,v 1.1.1.1 2003/01/21 11:50:40 yuichi Exp $
=end

class Digit

  attr_accessor :value

  def initialize( x )
    @value = x =~ /^0/ ? x.oct : x.to_i
  end

  def to_s( n=10 )
    case n
    when 8; @value == 0 ? '0' : '0%o' % @value
    when 16; '0x%X' % @value
    else @value.to_s
    end
  end

end
