class R3Status::Blocks::Clock

A block that displays the current date and time.

States

:am, :pm

Format values

See www.ruby-doc.org/core-2.1.3/Time.html#method-i-strftime

Public Class Methods

new(**args, &block) click to toggle source

Creates a new instance of this class. If a block is passed, it will be stored and yielded when the block is clicked.

Calls superclass method R3Status::Blocks::Base::new
# File lib/r3status/blocks/clock.rb, line 13
def initialize(**args, &block)
  args = {format: "%H:%m %e/%M/%Y"}.merge(args)
  super(args, &block)
end

Public Instance Methods

state() click to toggle source

Returns the current state of the block

# File lib/r3status/blocks/clock.rb, line 25
def state
  Time.now.strftime('%P').to_sym
end
update() click to toggle source

Updates the text and color of this block.

# File lib/r3status/blocks/clock.rb, line 19
def update
  self.full_text = Time.now.strftime(formats[state])
  self.text_color = colors[state]
end