Class: Warg::Localhost::CommandOutcome

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommandOutcome



632
633
634
635
636
# File 'lib/warg.rb', line 632

def initialize
  @console_status = Console::HostStatus.new(LOCALHOST, Warg.console)
  @started_at = nil
  @finished_at = nil
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



630
631
632
# File 'lib/warg.rb', line 630

def error
  @error
end

Instance Method Details

#command_finished!Object



653
654
655
656
657
658
659
660
661
662
# File 'lib/warg.rb', line 653

def command_finished!
  @finished_at = Time.now
  @finished_at.freeze

  if successful?
    @console_status.success!
  else
    @console_status.failed!(failure_summary)
  end
end

#command_started!Object



646
647
648
649
650
651
# File 'lib/warg.rb', line 646

def command_started!
  @started_at = Time.now
  @started_at.freeze

  @console_status.started!
end

#durationObject



680
681
682
683
684
# File 'lib/warg.rb', line 680

def duration
  if @started_at && @finished_at
    @finished_at - @started_at
  end
end

#failed?Boolean



668
669
670
# File 'lib/warg.rb', line 668

def failed?
  !successful?
end

#failure_summaryObject



686
687
688
# File 'lib/warg.rb', line 686

def failure_summary
  error && error.full_message
end

#finished?Boolean



676
677
678
# File 'lib/warg.rb', line 676

def finished?
  not @finished_at.nil?
end

#hostObject



638
639
640
# File 'lib/warg.rb', line 638

def host
  LOCALHOST
end

#started?Boolean



672
673
674
# File 'lib/warg.rb', line 672

def started?
  not @started_at.nil?
end

#successful?Boolean



664
665
666
# File 'lib/warg.rb', line 664

def successful?
  error.nil?
end

#valueObject



642
643
644
# File 'lib/warg.rb', line 642

def value
  self
end