Class: Kamaze::Project::Tools::Console::Output::Buffer

Inherits:
Object
  • Object
show all
Defined in:
lib/kamaze/project/tools/console/output/buffer.rb,
lib/kamaze/project/tools/console/output/buffer.rb

Overview

Describe a buffer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output, content) ⇒ Buffer

Returns a new instance of Buffer.

Parameters:



26
27
28
29
# File 'lib/kamaze/project/tools/console/output/buffer.rb', line 26

def initialize(output, content)
  @output = output
  @content = content
end

Instance Attribute Details

#contentString (readonly)

Get content

Returns:

  • (String)


22
23
24
# File 'lib/kamaze/project/tools/console/output/buffer.rb', line 22

def content
  @content
end

#outputKamaze::Project::Tools::Console::Output (readonly, protected)



39
40
41
# File 'lib/kamaze/project/tools/console/output/buffer.rb', line 39

def output
  @output
end

Instance Method Details

#decorate(str) ⇒ String (protected)

Decorate given string depending output is a tty

Parameters:

  • str (String)

Returns:

  • (String)


45
46
47
# File 'lib/kamaze/project/tools/console/output/buffer.rb', line 45

def decorate(str)
  CLI::UI.fmt(str.to_s, enable_color: output.tty?)
end

#to_sString

Returns:

  • (String)


32
33
34
# File 'lib/kamaze/project/tools/console/output/buffer.rb', line 32

def to_s
  self.decorate(content)
end