Module: CLI::UI::Frame::FrameStyle Abstract

Includes:
Kernel
Included in:
Box, Bracket
Defined in:
lib/cli/ui/frame/frame_style.rb,
lib/cli/ui/frame/frame_style/box.rb,
lib/cli/ui/frame/frame_style/bracket.rb

Overview

This module is abstract.

Defined Under Namespace

Modules: Box, Bracket Classes: InvalidFrameStyleName

Constant Summary collapse

MAP =
{
  box: -> { FrameStyle::Box },
  bracket: -> { FrameStyle::Bracket },
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.lookup(name) ⇒ Object

Lookup a frame style via its name

Attributes

  • symbol - frame style name to lookup

: ((String | Symbol) name) -> FrameStyle



28
29
30
31
32
# File 'lib/cli/ui/frame/frame_style.rb', line 28

def lookup(name)
  MAP.fetch(name.to_sym).call
rescue KeyError
  raise(InvalidFrameStyleName, name)
end

Instance Method Details

#close(text, color:, right_text: nil) ⇒ Object

This method is abstract.

Draws the “Close” line for this frame style

Attributes

  • text - (required) the text/title to output in the frame

Options

  • :color - (required) The color of the frame.

  • :right_text - Text to print at the right of the line. Defaults to nil

: (String, color: CLI::UI::Color, ?right_text: String?) -> String

Raises:

  • (NotImplementedError)


84
85
86
# File 'lib/cli/ui/frame/frame_style.rb', line 84

def close(text, color:, right_text: nil)
  raise(NotImplementedError)
end

#divider(text, color:) ⇒ Object

This method is abstract.

Draws a “divider” line for the current frame style

Attributes

  • text - (required) the text/title to output in the frame

Options

  • :color - (required) The color of the frame.

: (String, color: CLI::UI::Color) -> String

Raises:

  • (NotImplementedError)


100
101
102
# File 'lib/cli/ui/frame/frame_style.rb', line 100

def divider(text, color:)
  raise(NotImplementedError)
end

#prefixObject

This method is abstract.

Returns the character(s) that should be printed at the beginning of lines inside this frame : -> String

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/cli/ui/frame/frame_style.rb', line 45

def prefix
  raise(NotImplementedError)
end

#prefix_widthObject

Returns the printing width of the prefix : -> Integer



51
52
53
# File 'lib/cli/ui/frame/frame_style.rb', line 51

def prefix_width
  CLI::UI::ANSI.printing_width(prefix)
end

: (Integer x, String str) -> String



105
106
107
# File 'lib/cli/ui/frame/frame_style.rb', line 105

def print_at_x(x, str)
  CLI::UI::ANSI.cursor_horizontal_absolute(1 + x) + str
end

#start(text, color:) ⇒ Object

This method is abstract.

Draws the “Open” line for this frame style

Attributes

  • text - (required) the text/title to output in the frame

Options

  • :color - (required) The color of the frame.

: (String, color: CLI::UI::Color) -> String

Raises:

  • (NotImplementedError)


67
68
69
# File 'lib/cli/ui/frame/frame_style.rb', line 67

def start(text, color:)
  raise(NotImplementedError)
end

#style_nameObject

This method is abstract.

: -> Symbol

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/cli/ui/frame/frame_style.rb', line 37

def style_name
  raise(NotImplementedError)
end