class Engine
Attributes
auto_update[R]
hints[R]
parent[RW]
percent[R]
steps[R]
total_value[R]
value[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/completion-progress/engine.rb, line 7 def initialize(options = {}) @value = 0 @total_value = 0 @percent = 0 @hints = Hash.new @steps = Hash.new @auto_update = options.has_key?(:auto_update) ? options[:auto_update] : true end
Public Instance Methods
step(name, value, options = {}, &block)
click to toggle source
# File lib/completion-progress/engine.rb, line 16 def step(name, value, options = {}, &block) if !@steps.has_key?(name) @steps[name] = Step.new(name, value, options, &block) @total_value += value end end
update()
click to toggle source
# File lib/completion-progress/engine.rb, line 23 def update @value = 0 @hints = Hash.new @steps.each do |key, step| step.process(parent) ? @value += step.value : @hints[step.name] = step.hint end @percent = @value * 100 / @total_value end