Method: CLI::UI::Frame.prefix

Defined in:
lib/cli/ui/frame.rb

.prefix(color: Thread.current[:cliui_frame_color_override]) ⇒ Object

Determines the prefix of a frame entry taking multi-nested frames into account

Options

  • :color - The color of the prefix. Defaults to Thread.current[:cliui_frame_color_override]

: (?color: colorable?) -> String



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/cli/ui/frame.rb', line 224

def prefix(color: Thread.current[:cliui_frame_color_override])
  (+'').tap do |output|
    items = FrameStack.items

    items[0..-2].to_a.each do |item|
      output << item.color.code if CLI::UI.enable_color?
      output << item.frame_style.prefix
      output << CLI::UI::Color::RESET.code if CLI::UI.enable_color?
    end

    if (item = items.last)
      final_color = color || item.color
      output << CLI::UI.resolve_color(final_color).code if CLI::UI.enable_color?
      output << item.frame_style.prefix
      output << CLI::UI::Color::RESET.code if CLI::UI.enable_color?
      output << ' '
    end
  end
end