Class: Vaulty::Output::Banner

Inherits:
Object
  • Object
show all
Defined in:
lib/vaulty/output/banner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg, color: :blue, prompt:) ⇒ Banner

Returns a new instance of Banner.



6
7
8
9
10
# File 'lib/vaulty/output/banner.rb', line 6

def initialize(msg, color: :blue, prompt:)
  @msg = msg
  @color = "on_#{color}".to_sym
  @prompt = prompt
end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



4
5
6
# File 'lib/vaulty/output/banner.rb', line 4

def color
  @color
end

#msgObject (readonly)

Returns the value of attribute msg.



4
5
6
# File 'lib/vaulty/output/banner.rb', line 4

def msg
  @msg
end

#promptObject (readonly)

Returns the value of attribute prompt.



4
5
6
# File 'lib/vaulty/output/banner.rb', line 4

def prompt
  @prompt
end

Class Method Details

.render(*args) ⇒ Object



19
20
21
# File 'lib/vaulty/output/banner.rb', line 19

def self.render(*args)
  new(*args).render
end

Instance Method Details

#renderObject



12
13
14
15
16
17
# File 'lib/vaulty/output/banner.rb', line 12

def render
  now = Time.new.strftime('%H:%M:%S')
  formatted = msg.ljust(72, ' ')
  prompt.say("[#{now}] #{formatted}", color: %I(bold white #{color}))
  puts
end