Class: CWM::ProgressBar

Inherits:
CustomWidget show all
Defined in:
library/cwm/src/lib/cwm/progress_bar.rb

Overview

Widget for a progress bar

Examples:


class MyProgressBar < CWM::ProgessBar
  def steps
    ["step 1", "step 2", "step 3"]
  end
end

pg = MyProgressBar.new

pg.forward #=> shows label "step 1"
pg.forward #=> shows label "step 2"
pg.forward #=> shows label "step 3"

Direct Known Subclasses

DynamicProgressBar

Instance Attribute Summary

Attributes inherited from AbstractWidget

#handle_all_events, #widget_id

Instance Method Summary collapse

Methods inherited from CustomWidget

#cwm_contents, #cwm_definition, #find_ids, #ids_in_contents

Methods inherited from AbstractWidget

#cleanup, #cwm_definition, #disable, #enable, #enabled?, #focus, #fun_ref, #handle, #help, #init, #label, #my_event?, #opt, #refresh_help, #store, #validate, widget_type=

Constructor Details

#initializeProgressBar

Constructor


41
42
43
44
45
# File 'library/cwm/src/lib/cwm/progress_bar.rb', line 41

def initialize
  super

  @current_step_index = 0
end

Instance Method Details

#contentsObject


48
49
50
# File 'library/cwm/src/lib/cwm/progress_bar.rb', line 48

def contents
  ProgressBar(Id(widget_id), current_label, total_steps, current_step_index)
end

#forwardObject

Moves the progress forward and sets the next step as label if needed (see #show_steps?)


53
54
55
56
57
58
59
# File 'library/cwm/src/lib/cwm/progress_bar.rb', line 53

def forward
  return if complete?

  @current_step_index += 1

  refresh
end

#stepsArray<String>

Steps for the progress bar

Returns:

  • (Array<String>)

66
# File 'library/cwm/src/lib/cwm/progress_bar.rb', line 66

abstract_method :steps