Module: CLI::UI::Frame::FrameStyle::Interface

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

Overview

Public interface for FrameStyles Applied by extending FrameStyle

Instance Method Summary collapse

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

Raises:

  • (NotImplementedError)

94
95
96
# File 'lib/cli/ui/frame/frame_style.rb', line 94

def close(text, color:, right_text: nil)
  raise NotImplementedError, "#{self.class.name} must implement #{__method__}"
end

#divider(text, color: nil) ⇒ 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.

Raises:

  • (NotImplementedError)

108
109
110
# File 'lib/cli/ui/frame/frame_style.rb', line 108

def divider(text, color: nil)
  raise NotImplementedError, "#{self.class.name} must implement #{__method__}"
end

#nameObject

Because these are interface methods, we want to be explicit about their signatures, even if we don't use the arguments. rubocop:disable Lint/UnusedMethodArgument

Raises:

  • (NotImplementedError)

54
55
56
# File 'lib/cli/ui/frame/frame_style.rb', line 54

def name
  raise NotImplementedError, "#{self.class.name} must implement #{__method__}"
end

#open(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.

Raises:

  • (NotImplementedError)

79
80
81
# File 'lib/cli/ui/frame/frame_style.rb', line 79

def open(text, color:)
  raise NotImplementedError, "#{self.class.name} must implement #{__method__}"
end

#prefixObject

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

Raises:

  • (NotImplementedError)

60
61
62
# File 'lib/cli/ui/frame/frame_style.rb', line 60

def prefix
  raise NotImplementedError, "#{self.class.name} must implement #{__method__}"
end

#prefix_widthObject

Returns the printing width of the prefix


65
66
67
# File 'lib/cli/ui/frame/frame_style.rb', line 65

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