class Warg::Console::HostStatus

Attributes

row_number[RW]

Public Class Methods

new(host, console) click to toggle source
# File lib/warg.rb, line 426
def initialize(host, console)
  @host = host
  @console = console

  @hostname = host.address
  @state = Console::SGR("STARTING").with(text_color: :cyan)
  @failure_message = ""

  @console.puts self
end

Public Instance Methods

failed!(failure_message = "") click to toggle source
# File lib/warg.rb, line 451
def failed!(failure_message = "")
  @state = Console::SGR("FAILED").with(text_color: :red, effect: :bold)
  @failure_message = failure_message.to_s

  @console.reprint_content(self)
end
last_line_length() click to toggle source
# File lib/warg.rb, line 441
def last_line_length
  0
end
newline_count() click to toggle source
# File lib/warg.rb, line 437
def newline_count
  1 + @failure_message.count("\n")
end
started!() click to toggle source
# File lib/warg.rb, line 445
def started!
  @state = Console::SGR("RUNNING").with(text_color: :magenta)

  @console.reprint_content(self)
end
success!() click to toggle source
# File lib/warg.rb, line 458
def success!
  @state = Console::SGR("DONE").with(text_color: :green)

  @console.reprint_content(self)
end
to_s() click to toggle source
# File lib/warg.rb, line 464
def to_s
  content = "  %-#{Console.hostname_width}s\t[ %s ]\n" % [@hostname, @state]

  unless @failure_message.empty?
    indented_failure_message = @failure_message.each_line.
      map { |line| line.prepend("    ") }.
      join

    content << Console::SGR(indented_failure_message).with(text_color: :yellow)
  end

  content
end