Module: NattyUI::WithStatus
- Included in:
- ProgressHelper, Section, Task
- Defined in:
- lib/natty-ui/element.rb
Overview
Methods for elements with status like ProgressHelper, Section, Task.
Instance Attribute Summary collapse
-
#active? ⇒ true, false
readonly
Whether the element is still active.
-
#closed? ⇒ true, false
readonly
Whether the element is completed.
-
#failed? ⇒ true, false
readonly
Whether the element is completed with failure.
-
#status ⇒ Symbol?
readonly
Element's current status.
Instance Method Summary collapse
-
#failed(*text) {|failed| ... } ⇒ Features
Close the element with a failure.
-
#ok(*text) ⇒ Features
(also: #done)
Close the element.
-
#ok? ⇒ true, false
Whether the element is completed.
Instance Attribute Details
#active? ⇒ true, false (readonly)
Returns whether the element is still active.
62 |
# File 'lib/natty-ui/element.rb', line 62 def active? = @status.nil? |
#closed? ⇒ true, false (readonly)
Returns whether the element is completed.
66 |
# File 'lib/natty-ui/element.rb', line 66 def closed? = !active? |
#failed? ⇒ true, false (readonly)
Returns whether the element is completed with failure.
74 |
# File 'lib/natty-ui/element.rb', line 74 def failed? = @state == :failed |
#status ⇒ Symbol? (readonly)
Returns element's current status.
58 59 60 |
# File 'lib/natty-ui/element.rb', line 58 def status @status end |
Instance Method Details
#failed(*text) {|failed| ... } ⇒ Features
Close the element with a failure.
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/natty-ui/element.rb', line 95 def failed(*text, &block) return self if @state if text.empty? super(@title, &block).ok if @title else super.ok end @state = :failed _failed self.end end |
#ok(*text) ⇒ Features Also known as: done
Close the element.
80 81 82 83 84 85 86 |
# File 'lib/natty-ui/element.rb', line 80 def ok(*text) return self if @state text = [@title] if text.empty? && @title _done(text) @state = :ok self.end end |
#ok? ⇒ true, false
Returns whether the element is completed.
70 |
# File 'lib/natty-ui/element.rb', line 70 def ok? = @state == :ok |