Class: Progression::Progress

Inherits:
Object
  • Object
show all
Defined in:
lib/progression.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, steps) ⇒ Progress

Returns a new instance of Progress.



46
47
48
49
# File 'lib/progression.rb', line 46

def initialize(object, steps)
  @object = object
  @steps = steps
end

Instance Attribute Details

#stepsObject (readonly)

Returns the value of attribute steps.



44
45
46
# File 'lib/progression.rb', line 44

def steps
  @steps
end

Instance Method Details

#completed_stepsObject



51
52
53
54
55
# File 'lib/progression.rb', line 51

def completed_steps
  steps.select do |step|
    step.evaluate(@object)
  end
end

#next_stepObject



61
62
63
64
65
# File 'lib/progression.rb', line 61

def next_step
  steps.find do |step|
    !step.evaluate(@object)
  end
end

#percentage_completedObject



57
58
59
# File 'lib/progression.rb', line 57

def percentage_completed
  (completed_steps.size / steps.size.to_f) * 100
end