Class: HakumiComponents::Tour::Step
- Inherits:
-
Object
- Object
- HakumiComponents::Tour::Step
- Extended by:
- T::Sig
- Defined in:
- app/components/hakumi_components/tour/step.rb
Constant Summary collapse
- InputValue =
T.type_alias { T.nilable(Types::StringOrSymbol) }
- InputHash =
T.type_alias { T.any(T::Hash[Symbol, InputValue], T::Hash[String, InputValue]) }
- Source =
T.type_alias { T.any(Step, InputHash) }
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#placement ⇒ Object
readonly
Returns the value of attribute placement.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(title:, body:, placement:, target: nil) ⇒ Step
constructor
A new instance of Step.
- #to_h ⇒ Object
Constructor Details
#initialize(title:, body:, placement:, target: nil) ⇒ Step
Returns a new instance of Step.
21 22 23 24 25 26 |
# File 'app/components/hakumi_components/tour/step.rb', line 21 def initialize(title:, body:, placement:, target: nil) @title = title @body = body @target = target @placement = placement end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
32 33 34 |
# File 'app/components/hakumi_components/tour/step.rb', line 32 def body @body end |
#placement ⇒ Object (readonly)
Returns the value of attribute placement.
38 39 40 |
# File 'app/components/hakumi_components/tour/step.rb', line 38 def placement @placement end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
35 36 37 |
# File 'app/components/hakumi_components/tour/step.rb', line 35 def target @target end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
29 30 31 |
# File 'app/components/hakumi_components/tour/step.rb', line 29 def title @title end |
Class Method Details
.from_input(step, default_placement:) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/components/hakumi_components/tour/step.rb', line 41 def self.from_input(step, default_placement:) return step if step.is_a?(Step) title = read_input(step, :title).to_s body = read_input(step, :body, :description).to_s target = read_input(step, :target)&.to_s placement = (read_input(step, :placement) || default_placement).to_s.to_sym Step.new( title: title, body: body, placement: placement, target: target ) end |
Instance Method Details
#to_h ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'app/components/hakumi_components/tour/step.rb', line 58 def to_h { title: @title, body: @body, target: @target, placement: @placement.to_s.tr("_", "-") } end |