Module: CLI::UI::Frame::FrameStyle Abstract
- Includes:
- Kernel
- 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
Defined Under Namespace
Modules: Box, Bracket Classes: InvalidFrameStyleName
Constant Summary collapse
Class Method Summary collapse
-
.lookup(name) ⇒ Object
Lookup a frame style via its name.
Instance Method Summary collapse
-
#close(text, color:, right_text: nil) ⇒ Object
abstract
Draws the “Close” line for this frame style.
-
#divider(text, color:) ⇒ Object
abstract
Draws a “divider” line for the current frame style.
-
#prefix ⇒ Object
abstract
Returns the character(s) that should be printed at the beginning of lines inside this frame : -> String.
-
#prefix_width ⇒ Object
Returns the printing width of the prefix : -> Integer.
-
#print_at_x(x, str) ⇒ Object
: (Integer x, String str) -> String.
-
#start(text, color:) ⇒ Object
abstract
Draws the “Open” line for this frame style.
-
#style_name ⇒ Object
abstract
: -> Symbol.
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
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
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
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
100 101 102 |
# File 'lib/cli/ui/frame/frame_style.rb', line 100 def divider(text, color:) raise(NotImplementedError) end |
#prefix ⇒ Object
Returns the character(s) that should be printed at the beginning of lines inside this frame : -> String
45 46 47 |
# File 'lib/cli/ui/frame/frame_style.rb', line 45 def prefix raise(NotImplementedError) end |
#prefix_width ⇒ Object
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 |
#print_at_x(x, str) ⇒ Object
: (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
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
67 68 69 |
# File 'lib/cli/ui/frame/frame_style.rb', line 67 def start(text, color:) raise(NotImplementedError) end |
#style_name ⇒ Object
: -> Symbol
37 38 39 |
# File 'lib/cli/ui/frame/frame_style.rb', line 37 def style_name raise(NotImplementedError) end |