Class: StageManager

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

Defined Under Namespace

Classes: NoStagesSpecifiedError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stages) ⇒ StageManager

Returns a new instance of StageManager.



11
12
13
14
# File 'lib/auto_tagger/stage_manager.rb', line 11

def initialize(stages)
  raise NoStagesSpecifiedError unless stages && stages.is_a?(Array)
  @stages = stages
end

Instance Attribute Details

#stagesObject (readonly)

Returns the value of attribute stages.



9
10
11
# File 'lib/auto_tagger/stage_manager.rb', line 9

def stages
  @stages
end

Instance Method Details

#previous_stage(stage) ⇒ Object



16
17
18
19
20
21
# File 'lib/auto_tagger/stage_manager.rb', line 16

def previous_stage(stage)
  if stage
    index = stages.index(stage) - 1
    stages[index] if index > -1
  end
end