Class: Barabara::Modules::Clock

Inherits:
Object
  • Object
show all
Includes:
Wisper::Publisher
Defined in:
lib/barabara/modules/clock.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClock

Returns a new instance of Clock.



6
7
8
9
10
11
# File 'lib/barabara/modules/clock.rb', line 6

def initialize
  config = GlobalConfig.config.module_config('clock')
  colors = GlobalConfig.config.colors
  @format = format(config['format'], colors) || '%F %R'
  @time = Time.now
end

Instance Attribute Details

#timeObject (readonly)

Returns the value of attribute time.



13
14
15
# File 'lib/barabara/modules/clock.rb', line 13

def time
  @time
end

Instance Method Details

#watchObject



15
16
17
18
19
20
21
# File 'lib/barabara/modules/clock.rb', line 15

def watch
  loop do
    update
    push
    sleep 5
  end
end