Module: CLI::UI::Frame::FrameStack

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

Defined Under Namespace

Classes: StackItem

Class Method Summary collapse

Class Method Details

.itemsObject

Fetch all items off the frame stack : -> Array



25
26
27
# File 'lib/cli/ui/frame/frame_stack.rb', line 25

def items
  Thread.current[:cliui_frame_stack] ||= []
end

.popObject

Removes and returns the last stack item off the stack : -> StackItem?



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

def pop
  items.pop
end

.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