Module: Rbtclk
- Defined in:
- lib/rbtclk/version.rb,
lib/rbtclk.rb,
lib/rbtclk/clock.rb,
lib/rbtclk/color_code.rb,
lib/rbtclk/countup_timer.rb,
lib/rbtclk/countdown_timer.rb
Overview
Defined Under Namespace
Modules: ColorCode
Classes: Clock, CountdownTimer, CountupTimer
Constant Summary
collapse
- VERSION =
"0.3.2"
Class Method Summary
collapse
Class Method Details
Methods for configuration DSL
85
86
87
|
# File 'lib/rbtclk.rb', line 85
def configure(&block)
Rbtclk.instance_eval(&block)
end
|
.display_clock(params) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/rbtclk.rb', line 35
def display_clock(params)
params = fill(params)
case params[:mode]
when "clock"
(params)
timer = Clock.new(params)
timer.show
when "countup"
(params)
timer = CountupTimer.new(params)
timer.show
when "countdown"
(params)
timer = CountdownTimer.new(params)
timer.show
else
warn "#{params[:mode]} mode is not supported."
warn "You can use [clock, countup, countdown]."
exit(1)
end
end
|
.fill(params) ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/rbtclk.rb', line 58
def fill(params)
{mode: params[:mode] || MODE,
font: params[:font] || FONT,
format: params[:format] || FORMAT,
color: params[:color] || COLOR,
time: params[:time] || TIME}
end
|
.load_config ⇒ Object
74
75
76
77
78
79
80
81
82
|
# File 'lib/rbtclk.rb', line 74
def load_config
dot_rbtclk_in_home = File.expand_path(".rbtclk", "~")
if File.exist?(dot_rbtclk_in_home)
load dot_rbtclk_in_home
else
load File.expand_path("../../config/default.rb", __FILE__)
end
end
|
66
67
68
69
70
71
72
|
# File 'lib/rbtclk.rb', line 66
def (params)
params.delete(:mode)
if params[:mode] != "countdown"
params.delete(:time)
end
end
|
.run(args) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/rbtclk.rb', line 14
def run(args)
params = {}
OptionParser.new do |opt|
opt.on("--mode MODE") { |m| params[:mode] = m }
opt.on("--format FORMAT") { |f| params[:format] = f }
opt.on("--font FONT") { |f| params[:font] = f }
opt.on("--version") { |v| params[:version] = v }
opt.on("--color COLOR") { |c| params[:color] = c }
opt.on("--time TIME") { |t| params[:time] = t }
opt.parse!(args)
end
if params[:version]
puts Rbtclk::VERSION
else
display_clock(params)
end
end
|