Module: CLI::UI::Frame::FrameStack
- Extended by:
- T::Sig
- Defined in:
- lib/cli/ui/frame/frame_stack.rb
Defined Under Namespace
Classes: StackItem
Constant Summary collapse
- COLOR_ENVVAR =
'CLI_FRAME_STACK'
- STYLE_ENVVAR =
'CLI_STYLE_STACK'
Class Method Summary collapse
Methods included from T::Sig
Class Method Details
.items ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/cli/ui/frame/frame_stack.rb', line 34 def items colors = ENV.fetch(COLOR_ENVVAR, '').split(':').map(&:to_sym) styles = ENV.fetch(STYLE_ENVVAR, '').split(':').map(&:to_sym) colors.each_with_index.map do |color, i| StackItem.new(color, styles[i] || Frame.frame_style) end end |
.pop ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/cli/ui/frame/frame_stack.rb', line 84 def pop curr = items ret = curr.pop serialize(curr) ret.nil? ? nil : ret end |
.push(item = nil, color: nil, style: nil) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cli/ui/frame/frame_stack.rb', line 69 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 item ||= StackItem.new(T.must(color), T.must(style)) curr = items curr << item serialize(curr) end |