Class: Warg::Console::HostStatus
- Inherits:
-
Object
- Object
- Warg::Console::HostStatus
- Defined in:
- lib/warg.rb
Instance Attribute Summary collapse
-
#row_number ⇒ Object
Returns the value of attribute row_number.
Instance Method Summary collapse
- #failed!(failure_message = "") ⇒ Object
-
#initialize(host, console) ⇒ HostStatus
constructor
A new instance of HostStatus.
- #last_line_length ⇒ Object
- #newline_count ⇒ Object
- #started! ⇒ Object
- #success! ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(host, console) ⇒ HostStatus
Returns a new instance of HostStatus.
426 427 428 429 430 431 432 433 434 435 |
# 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 |
Instance Attribute Details
#row_number ⇒ Object
Returns the value of attribute row_number.
424 425 426 |
# File 'lib/warg.rb', line 424 def row_number @row_number end |
Instance Method Details
#failed!(failure_message = "") ⇒ Object
451 452 453 454 455 456 |
# File 'lib/warg.rb', line 451 def failed!( = "") @state = Console::SGR("FAILED").with(text_color: :red, effect: :bold) @failure_message = .to_s @console.reprint_content(self) end |
#last_line_length ⇒ Object
441 442 443 |
# File 'lib/warg.rb', line 441 def last_line_length 0 end |
#newline_count ⇒ Object
437 438 439 |
# File 'lib/warg.rb', line 437 def newline_count 1 + @failure_message.count("\n") end |
#started! ⇒ Object
445 446 447 448 449 |
# File 'lib/warg.rb', line 445 def started! @state = Console::SGR("RUNNING").with(text_color: :magenta) @console.reprint_content(self) end |
#success! ⇒ Object
458 459 460 461 462 |
# File 'lib/warg.rb', line 458 def success! @state = Console::SGR("DONE").with(text_color: :green) @console.reprint_content(self) end |
#to_s ⇒ Object
464 465 466 467 468 469 470 471 472 473 474 475 476 |
# File 'lib/warg.rb', line 464 def to_s content = " %-#{Console.hostname_width}s\t[ %s ]\n" % [@hostname, @state] unless @failure_message.empty? = @failure_message.each_line. map { |line| line.prepend(" ") }. join content << Console::SGR().with(text_color: :yellow) end content end |