Class: Vixen::CommandLine::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/vixen/command_line/base.rb

Direct Known Subclasses

Halt, Resume, Snapshot, Status, Suspend, Up

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



4
5
6
# File 'lib/vixen/command_line/base.rb', line 4

def initialize
  @start = Time.now
end

Instance Attribute Details

#startObject (readonly)

Returns the value of attribute start.



2
3
4
# File 'lib/vixen/command_line/base.rb', line 2

def start
  @start
end

Instance Method Details

#elapsed_timeObject



8
9
10
# File 'lib/vixen/command_line/base.rb', line 8

def elapsed_time
  "[%s]" % (Time.at(Time.now - start).utc.strftime '%T')
end

#new_line_afterObject



12
13
14
15
16
# File 'lib/vixen/command_line/base.rb', line 12

def new_line_after
  val = yield if block_given?
  puts
  val
end


18
19
20
21
22
# File 'lib/vixen/command_line/base.rb', line 18

def print(message, *args)
  timed_message = "\r             \r#{elapsed_time} " + message
  $stdout.print timed_message, args
  $stdout.flush
end