Class: CWM::DynamicProgressBar

Inherits:
ProgressBar show all
Defined in:
library/cwm/src/lib/cwm/dynamic_progress_bar.rb

Overview

Widget for a dynamic progress bar, where the label can be set for every step.

This progress bar is useful when steps are not known in advance or part of them are dynamically generated.

Examples:


class MyProgressBar < CWM::DynamicProgessBar
  def steps_count
    3
  end

  def label
    "Progress"
  end
end

pg = MyProgressBar.new

pg.forward("step 1") #=> shows label "step 1"
pg.forward           #=> shows label "Progress"
pg.forward("step 3") #=> shows label "step 3"

Instance Attribute Summary

Attributes inherited from AbstractWidget

#handle_all_events, #widget_id

Instance Method Summary collapse

Methods inherited from ProgressBar

#contents, #initialize

Methods inherited from CustomWidget

#contents, #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, #my_event?, #opt, #refresh_help, #store, #validate, widget_type=

Constructor Details

This class inherits a constructor from CWM::ProgressBar

Instance Method Details

#forward(step = nil) ⇒ Object

Moves the progress forward and sets the given step as label


50
51
52
53
54
# File 'library/cwm/src/lib/cwm/dynamic_progress_bar.rb', line 50

def forward(step = nil)
  next_step(step) if step

  super()
end

#labelString

Label for the progress bar when no step is given, see #forward.

Returns:

  • (String)

61
# File 'library/cwm/src/lib/cwm/dynamic_progress_bar.rb', line 61

abstract_method :label

#steps_countInteger

Number of steps

Returns:

  • (Integer)

68
# File 'library/cwm/src/lib/cwm/dynamic_progress_bar.rb', line 68

abstract_method :steps_count