Class: NattyUI::Temporary

Inherits:
Element
  • Object
show all
Defined in:
lib/natty-ui/temporary.rb

Overview

An Element whose output is erased from the terminal when it is closed.

Instances are created by Features#temporary. Any content printed inside a Temporary block disappears when the element is closed. Content printed with Features#pin is exempt — it is collected and reprinted after the erasure so it remains visible.

All Features methods are available on this element.

Examples:

Via block (auto-close)

ui.temporary do
  ui.puts 'Thinking…'
  sleep 2
end  # "Thinking…" is erased here

Manual close

ui.temporary
ui.puts 'Loading…'
do_work
ui.end   # erases "Loading…"

Direct Known Subclasses

Progress, Task