#!/usr/bin/env ruby
# coding: utf-8

require 'curses'

Curses.init_screen

begin
  
  class Clock
    
    def initialize
      @@week = ["日","月","火","水","木","金","土"]
    end

    def question
      while true
        Curses.addstr("時計(1)")
        select = Curses.getch
        if select == "1"
          clock
        elsif select == "2"
        end
        Curses.close_screen
      end
    end
    
    def clock
      time =  Time.now
      while true
        toki = sprintf("%s年%s月%s日%s曜日%s時%s分%s秒%s",time.year,time.mon,time.day,@@week[time.wday],time.hour,time.min,time.sec,time.usec/10000)
        Curses.addstr(toki)
        Curses.refresh
        time = Time.now
        Curses.close_screen
      end  
    end
    
  end
  
  x = Clock.new
  x.question
  
ensure
  Curses.close_screen
end

