Class: Rabbit::Progress
- Inherits:
-
Object
- Object
- Rabbit::Progress
- Defined in:
- lib/rabbit/progress.rb
Instance Attribute Summary collapse
-
#background ⇒ Object
Returns the value of attribute background.
-
#foreground ⇒ Object
Returns the value of attribute foreground.
-
#window ⇒ Object
readonly
Returns the value of attribute window.
Instance Method Summary collapse
- #clear_color ⇒ Object
- #end_progress ⇒ Object
- #hide ⇒ Object
-
#initialize ⇒ Progress
constructor
A new instance of Progress.
- #start_progress(max, parent) ⇒ Object
- #update_progress(i) ⇒ Object
Constructor Details
#initialize ⇒ Progress
Returns a new instance of Progress.
6 7 8 9 10 11 |
# File 'lib/rabbit/progress.rb', line 6 def initialize @width = 100 @height = 20 @foreground = nil @background = nil end |
Instance Attribute Details
#background ⇒ Object
Returns the value of attribute background.
5 6 7 |
# File 'lib/rabbit/progress.rb', line 5 def background @background end |
#foreground ⇒ Object
Returns the value of attribute foreground.
5 6 7 |
# File 'lib/rabbit/progress.rb', line 5 def foreground @foreground end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
5 6 7 |
# File 'lib/rabbit/progress.rb', line 5 def window @window end |
Instance Method Details
#clear_color ⇒ Object
21 22 23 24 |
# File 'lib/rabbit/progress.rb', line 21 def clear_color @foreground = nil @background = nil end |
#end_progress ⇒ Object
49 50 51 52 53 54 |
# File 'lib/rabbit/progress.rb', line 49 def end_progress return if @max.nil? @current = @max @bar.fraction = @current / @max end |
#hide ⇒ Object
56 57 58 59 60 61 |
# File 'lib/rabbit/progress.rb', line 56 def hide @max = nil @window.destroy @bar = nil @window = nil end |
#start_progress(max, parent) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rabbit/progress.rb', line 26 def start_progress(max, parent) return if max.zero? @window = Gtk::Window.new(:popup) @window.transient_for = parent @window.app_paintable = true @window.set_default_size(@width, @height) @bar = Gtk::ProgressBar.new @window.add(@bar) @window.show_all @bar.fraction = @current = 0 @max = max.to_f setup_progress_color end |
#update_progress(i) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/rabbit/progress.rb', line 42 def update_progress(i) return if @max.nil? @current = i @bar.fraction = @current / @max end |