Class: Dex::UI::Spinner::SpinGroup::Task
- Inherits:
-
Object
- Object
- Dex::UI::Spinner::SpinGroup::Task
- Defined in:
- lib/dex/ui/spinner.rb
Instance Attribute Summary collapse
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(title, &block) ⇒ Task
constructor
A new instance of Task.
- #render(index, force = true) ⇒ Object
Constructor Details
#initialize(title, &block) ⇒ Task
Returns a new instance of Task.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dex/ui/spinner.rb', line 31 def initialize(title, &block) @title = title @thread = Thread.new do cap = Dex::UI::StdoutRouter::Capture.new(with_frame_inset: false, &block) begin cap.run ensure @stdout = cap.stdout @stderr = cap.stderr end end @done = false @exception = nil @success = false end |
Instance Attribute Details
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
29 30 31 |
# File 'lib/dex/ui/spinner.rb', line 29 def exception @exception end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
29 30 31 |
# File 'lib/dex/ui/spinner.rb', line 29 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
29 30 31 |
# File 'lib/dex/ui/spinner.rb', line 29 def stdout @stdout end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
29 30 31 |
# File 'lib/dex/ui/spinner.rb', line 29 def success @success end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
29 30 31 |
# File 'lib/dex/ui/spinner.rb', line 29 def title @title end |
Instance Method Details
#check ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/dex/ui/spinner.rb', line 48 def check return true if @done return false if @thread.alive? @done = true begin status = @thread.join.status @success = (status == false) rescue => exc @exception = exc @success = false end @done end |
#render(index, force = true) ⇒ Object
64 65 66 67 |
# File 'lib/dex/ui/spinner.rb', line 64 def render(index, force = true) return full_render(index) if force partial_render(index) end |