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| ... } ⇒ Element
Close the element with a failure.
-
#ok(*text) ⇒ Element
(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.
57 |
# File 'lib/natty-ui/element.rb', line 57 def active? = @status.nil? |
#closed? ⇒ true, false (readonly)
Returns whether the element is completed.
61 |
# File 'lib/natty-ui/element.rb', line 61 def closed? = !active? |
#failed? ⇒ true, false (readonly)
Returns whether the element is completed with failure.
69 |
# File 'lib/natty-ui/element.rb', line 69 def failed? = @state == :failed |
#status ⇒ Symbol? (readonly)
Returns element's current status.
53 54 55 |
# File 'lib/natty-ui/element.rb', line 53 def status @status end |
Instance Method Details
#failed(*text) {|failed| ... } ⇒ Element
Close the element with a failure.
90 91 92 93 94 95 96 97 |
# File 'lib/natty-ui/element.rb', line 90 def failed(*text, &block) return self if @state _failed @state = :failed text = [@title] if text.empty? && @title @parent.failed(*text, &block) self end |
#ok(*text) ⇒ Element Also known as: done
Close the element.
75 76 77 78 79 80 81 |
# File 'lib/natty-ui/element.rb', line 75 def ok(*text) return self if @state text = [@title] if text.empty? && @title _done(text) @state = :ok self end |
#ok? ⇒ true, false
Returns whether the element is completed.
65 |
# File 'lib/natty-ui/element.rb', line 65 def ok? = @state == :ok |