Class: Hansi::ColorRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/hansi/color_renderer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode: Hansi.mode, join: "") ⇒ ColorRenderer

Returns a new instance of ColorRenderer.


9
10
11
12
# File 'lib/hansi/color_renderer.rb', line 9

def initialize(mode: Hansi.mode, join: "")
  @mode  = mode
  @join  = join
end

Class Method Details

.render(*input, **options) ⇒ Object


5
6
7
# File 'lib/hansi/color_renderer.rb', line 5

def self.render(*input, **options)
  new(**options).render(*input)
end

Instance Method Details

#render(color, *input) ⇒ Object


14
15
16
17
18
# File 'lib/hansi/color_renderer.rb', line 14

def render(color, *input)
  output  = color.to_ansi(mode: @mode)
  output += input.join(@join) + Hansi.reset if input.any?
  output
end