Class: DsfrComponent::StepperComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/dsfr_component/stepper_component.rb

Constant Summary

Constants inherited from Base

Base::HEADING_LEVELS

Instance Attribute Summary

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Constructor Details

#initialize(title:, value:, max:, next_title: nil, classes: [], html_attributes: {}) ⇒ StepperComponent

Returns a new instance of StepperComponent.

Parameters:

  • title (String)

    Titre de l’étape en cours

  • value (Integer)

    Numéro de l’étape en cours (commence à 1)

  • max (Integer)

    Nombre d’étapes total

  • next_title (String) (defaults to: nil)

    Titre de l’étape suivante (sauf pour la dernière étape)

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
# File 'app/components/dsfr_component/stepper_component.rb', line 7

def initialize(title:, value:, max:, next_title: nil, classes: [], html_attributes: {})
  @title = title
  @value = value
  @max = max
  @next_title = next_title

  raise ArgumentError, "Les étapes doivent aller de 1 jusqu´à 8 au maximum" if @value < 1 || @value > @max || @max > 8

  super(classes: classes, html_attributes: html_attributes)
end