~ubuntu-branches/ubuntu/intrepid/ruby1.8/intrepid-updates

« back to all changes in this revision

Viewing changes to ext/tk/lib/tk/clock.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# tk/clock.rb : methods for clock command
 
3
#
 
4
require 'tk'
 
5
 
 
6
module Tk
 
7
  module Clock
 
8
    include Tk
 
9
    extend TkCore
 
10
 
 
11
    def self.add(clk, *args)
 
12
      tk_call_without_enc('clock','add', clk, *args).to_i
 
13
    end
 
14
 
 
15
    def self.clicks(ms=nil)
 
16
      ms = ms.to_s if ms.kind_of?(Symbol)
 
17
      case ms
 
18
      when nil, ''
 
19
        tk_call_without_enc('clock','clicks').to_i
 
20
      when /^mic/
 
21
        tk_call_without_enc('clock','clicks','-microseconds').to_i
 
22
      when /^mil/
 
23
        tk_call_without_enc('clock','clicks','-milliseconds').to_i
 
24
      else
 
25
        tk_call_without_enc('clock','clicks','-milliseconds').to_i
 
26
      end
 
27
    end
 
28
 
 
29
    def self.format(clk, form=nil)
 
30
      if form
 
31
        tk_call('clock','format',clk,'-format',form)
 
32
      else
 
33
        tk_call('clock','format',clk)
 
34
      end
 
35
    end
 
36
 
 
37
    def self.formatGMT(clk, form=nil)
 
38
      if form
 
39
        tk_call('clock','format',clk,'-format',form,'-gmt','1')
 
40
      else
 
41
        tk_call('clock','format',clk,'-gmt','1')
 
42
      end
 
43
    end
 
44
 
 
45
    def self.scan(str, base=nil)
 
46
      if base
 
47
        tk_call('clock','scan',str,'-base',base).to_i
 
48
      else
 
49
        tk_call('clock','scan',str).to_i
 
50
      end
 
51
    end
 
52
 
 
53
    def self.scanGMT(str, base=nil)
 
54
      if base
 
55
        tk_call('clock','scan',str,'-base',base,'-gmt','1').to_i
 
56
      else
 
57
        tk_call('clock','scan',str,'-gmt','1').to_i
 
58
      end
 
59
    end
 
60
 
 
61
    def self.seconds
 
62
      tk_call_without_enc('clock','seconds').to_i
 
63
    end
 
64
    def self.milliseconds
 
65
      tk_call_without_enc('clock','milliseconds').to_i
 
66
    end
 
67
    def self.microseconds
 
68
      tk_call_without_enc('clock','microseconds').to_i
 
69
    end
 
70
  end
 
71
end