Class: ChefCLI::UI

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-cli/ui.rb

Defined Under Namespace

Classes: NullStream

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out: nil, err: nil) ⇒ UI

Returns a new instance of UI.



40
41
42
43
# File 'lib/chef-cli/ui.rb', line 40

def initialize(out: nil, err: nil)
  @out_stream = out || $stdout
  @err_stream = err || $stderr
end

Instance Attribute Details

#err_streamObject (readonly)

Returns the value of attribute err_stream.



38
39
40
# File 'lib/chef-cli/ui.rb', line 38

def err_stream
  @err_stream
end

#out_streamObject (readonly)

Returns the value of attribute out_stream.



37
38
39
# File 'lib/chef-cli/ui.rb', line 37

def out_stream
  @out_stream
end

Class Method Details

.nullObject



33
34
35
# File 'lib/chef-cli/ui.rb', line 33

def self.null
  new(out: NullStream.new, err: NullStream.new)
end

Instance Method Details

#err(message) ⇒ Object



45
46
47
# File 'lib/chef-cli/ui.rb', line 45

def err(message)
  @err_stream.puts(message)
end

#msg(message) ⇒ Object



49
50
51
# File 'lib/chef-cli/ui.rb', line 49

def msg(message)
  @out_stream.puts(message)
end


53
54
55
# File 'lib/chef-cli/ui.rb', line 53

def print(message)
  @out_stream.print(message)
end