Module: Wizardry::Base::WizardryMethods

Defined in:
lib/wizardry/base.rb

Instance Method Summary collapse

Instance Method Details

#current_stepObject



29
30
31
# File 'lib/wizardry/base.rb', line 29

def current_step
  @current_step ||= first_step
end

#current_step=(step) ⇒ Object



33
34
35
36
# File 'lib/wizardry/base.rb', line 33

def current_step=(step)
  step = step.to_s
  @current_step = step.inquiry if steps.include?(step)
end

#next_stepObject



38
39
40
# File 'lib/wizardry/base.rb', line 38

def next_step
  steps[current_step_idx + 1] unless last_step?
end

#previous_stepObject



42
43
44
# File 'lib/wizardry/base.rb', line 42

def previous_step
  steps[current_step_idx - 1] unless first_step?
end

#step_title(step = current_step) ⇒ Object



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

def step_title(step = current_step)
  return nil if step !~ steps_regexp
  I18n.translate(step, scope: 'wizardry.steps', default: step.to_s.humanize)
end