Class: Diary::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/diary/message.rb

Defined Under Namespace

Modules: Shorthand

Constant Summary collapse

DEFAULT_PADDING =
12
CLEAR =

Embed in a String to clear all previous ANSI sequences.

"\e[0m"
BOLD =

Embed in a String to add bold

"\e[1m"
BLACK =

Embed in a String to add color

"\e[30m"
RED =
"\e[31m"
GREEN =
"\e[32m"
YELLOW =
"\e[33m"
BLUE =
"\e[34m"
MAGENTA =
"\e[35m"
CYAN =
"\e[36m"
WHITE =
"\e[37m"

Instance Method Summary collapse

Constructor Details

#initialize(keyword, message, color = false) ⇒ Message

Returns a new instance of Message.



19
20
21
22
23
24
# File 'lib/diary/message.rb', line 19

def initialize(keyword, message, color = false)
  keyword  = add_padding(keyword.to_s)
  keyword  = set_color(keyword, color) if color

  $stdout.puts "#{keyword} #{message}"
end