Module: ZTK::Command::Private

Included in:
ZTK::Command
Defined in:
lib/ztk/command/private.rb

Overview

Command Private Functionality

Instance Method Summary (collapse)

Instance Method Details

- (Object) log_header(what, char = "=")

Formats a header suitable for writing to the direct logger when logging sessions.



16
17
18
19
20
21
# File 'lib/ztk/command/private.rb', line 16

def log_header(what, char="=")
  count = 16
  sep = (char * count)
  header = [sep, "[ #{tag} >>> #{what} ]", sep].join
  "#{header}\n"
end

- (Object) tag

Returns a string in the format of "user@hostname" for the current shell.



9
10
11
12
# File 'lib/ztk/command/private.rb', line 9

def tag
  @@hostname ||= Socket.gethostname.split('.').first.strip
  "#{ENV['USER']}@#{@@hostname}"
end