Class: Zerenity::ProgressProxy
- Inherits:
-
Object
- Object
- Zerenity::ProgressProxy
- Defined in:
- lib/zerenity/progress.rb
Overview
ProgressProxy allows you to update the progress of the Zerenity::Progress dialog. It also can alert the processing block whether or not the Cancel button has been clicked.
Instance Attribute Summary collapse
-
#cancelled ⇒ Object
readonly
An attribute indicating whether the Cancel button has been clicked.
Instance Method Summary collapse
-
#cancel! ⇒ Object
:nodoc:.
-
#cancelled? ⇒ Boolean
Alias for cancelled.
-
#initialize ⇒ ProgressProxy
constructor
:nodoc:.
-
#percentage=(percentage) ⇒ Object
Sets the percentage complete of the progress bar.
-
#progressBar=(progressBar) ⇒ Object
:nodoc:.
-
#pulse(text = nil) ⇒ Object
When called will put the progress bar into ‘pulse’ mode.
-
#text=(text) ⇒ Object
Sets the text in the progress area.
-
#update(percentage, text = nil) ⇒ Object
Updates the progress bar.
Constructor Details
#initialize ⇒ ProgressProxy
:nodoc:
90 91 92 93 |
# File 'lib/zerenity/progress.rb', line 90 def initialize() # :nodoc: @progressBar = nil @cancelled = false end |
Instance Attribute Details
#cancelled ⇒ Object (readonly)
An attribute indicating whether the Cancel button has been clicked.
88 89 90 |
# File 'lib/zerenity/progress.rb', line 88 def cancelled @cancelled end |
Instance Method Details
#cancel! ⇒ Object
:nodoc:
132 133 134 |
# File 'lib/zerenity/progress.rb', line 132 def cancel! #:nodoc: @cancelled = true end |
#cancelled? ⇒ Boolean
Alias for cancelled.
128 129 130 |
# File 'lib/zerenity/progress.rb', line 128 def cancelled? @cancelled end |
#percentage=(percentage) ⇒ Object
Sets the percentage complete of the progress bar. Must be in the range 0-1.
123 124 125 |
# File 'lib/zerenity/progress.rb', line 123 def percentage=(percentage) @progressBar.fraction = percentage.to_f end |
#progressBar=(progressBar) ⇒ Object
:nodoc:
95 96 97 |
# File 'lib/zerenity/progress.rb', line 95 def progressBar=(progressBar) # :nodoc: @progressBar = progressBar end |
#pulse(text = nil) ⇒ Object
When called will put the progress bar into ‘pulse’ mode. A small bar will move forwards and backwards across the progress area.
112 113 114 115 |
# File 'lib/zerenity/progress.rb', line 112 def pulse(text=nil) @progressBar.text = text.to_s if text @progressBar.pulse end |
#text=(text) ⇒ Object
Sets the text in the progress area.
118 119 120 |
# File 'lib/zerenity/progress.rb', line 118 def text=(text) @progressBar.text = text.to_s end |
#update(percentage, text = nil) ⇒ Object
Updates the progress bar.
Parameters
- percentage
-
The percentage completed. Values range from 0 to 1.
- text
-
Optional text that will be displayed in the progress area.
104 105 106 107 |
# File 'lib/zerenity/progress.rb', line 104 def update(percentage,text=nil) @progressBar.text = text.to_s if text @progressBar.fraction = percentage.to_f end |