Class: Vagrant::UI::Interface

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

Overview

Vagrant UIs handle communication with the outside world (typically through a shell). They must respond to the following methods:

  • info
  • warn
  • error
  • success

Direct Known Subclasses

Basic, MachineReadable, Prefixed, Silent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInterface

Returns a new instance of Interface.


33
34
35
36
37
38
39
40
# File 'lib/vagrant/ui.rb', line 33

def initialize
  @logger   = Log4r::Logger.new("vagrant::ui::interface")
  @opts     = {}

  @stdin  = $stdin
  @stdout = $stdout
  @stderr = $stderr
end

Instance Attribute Details

#optsObject

Opts can be used to set some options. These options are implementation specific. See the implementation for more docs.


22
23
24
# File 'lib/vagrant/ui.rb', line 22

def opts
  @opts
end

#stderrIO

Returns UI error output. Defaults to $stderr.

Returns:

  • (IO)

    UI error output. Defaults to $stderr.


31
32
33
# File 'lib/vagrant/ui.rb', line 31

def stderr
  @stderr
end

#stdinIO

Returns UI input. Defaults to $stdin.

Returns:

  • (IO)

    UI input. Defaults to $stdin.


25
26
27
# File 'lib/vagrant/ui.rb', line 25

def stdin
  @stdin
end

#stdoutIO

Returns UI output. Defaults to $stdout.

Returns:

  • (IO)

    UI output. Defaults to $stdout.


28
29
30
# File 'lib/vagrant/ui.rb', line 28

def stdout
  @stdout
end

Instance Method Details

#color?false

Returns:

  • (false)

67
68
69
# File 'lib/vagrant/ui.rb', line 67

def color?
  return false
end

#initialize_copy(original) ⇒ Object


42
43
44
45
# File 'lib/vagrant/ui.rb', line 42

def initialize_copy(original)
  super
  @opts = original.opts.dup
end

#machine(type, *data) ⇒ Object

For machine-readable output.

Parameters:

  • type (String)

    The type of the data

  • data (Array)

    The data associated with the type


75
76
77
# File 'lib/vagrant/ui.rb', line 75

def machine(type, *data)
  @logger.info("Machine: #{type} #{data.inspect}")
end

#rewriting {|_self| ... } ⇒ Object

Yields self (UI) Provides a way for selectively displaying or not displaying updating content like download progress.

Yields:

  • (_self)

Yield Parameters:


82
83
84
# File 'lib/vagrant/ui.rb', line 82

def rewriting
  yield self
end