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:



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

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

Instance Attribute Details

#contentString (readonly)

Get content

Returns:

  • (String)


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

def content
  @content
end

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



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

def output
  @output
end

Instance Method Details

#decorate(str) ⇒ String (protected)

Decorate given string depending output is a tty

Parameters:

  • str (String)

Returns:

  • (String)


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

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

#to_sString

Returns:

  • (String)


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

def to_s
  self.decorate(content)
end

#uiObject (protected)



48
49
50
51
52
# File 'lib/kamaze/project/tools/console/output/buffer.rb', line 48

def ui
  require 'cli/ui'

  CLI::UI
end