Method: CLI::UI::Frame::FrameStack.push

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

.push(item = nil, color: nil, style: nil) ⇒ Object

Push a new item onto the frame stack.

Either an item or a :color/:style pair should be pushed onto the stack.

Attributes

  • item a StackItem to push onto the stack. Defaults to nil

Options

  • :color the color of the new stack item. Defaults to nil

  • :style the style of the new stack item. Defaults to nil

Raises

If both an item and a color/style pair are given, raises an ArgumentError If the given item is not a StackItem, raises an ArgumentError

: (?StackItem? item, ?color: CLI::UI::Color?, ?style: CLI::UI::Frame::FrameStyle?) -> void



48
49
50
51
52
53
54
55
56
# File 'lib/cli/ui/frame/frame_stack.rb', line 48

def push(item = nil, color: nil, style: nil)
  if color.nil? != style.nil? || item.nil? == color.nil?
    raise ArgumentError, 'Must give one of item or color: and style:'
  end

  c = color #: as !nil
  s = style #: as !nil
  items.push(item || StackItem.new(c, s))
end