Class: HakumiComponents::Skeleton::TitleConfig

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
app/components/hakumi_components/skeleton/title_config.rb

Constant Summary collapse

WidthValue =
T.type_alias { T.any(Integer, String) }
Input =
T.type_alias { T.any(T::Boolean, Types::HtmlAttributes, HakumiComponents::Skeleton::TitleConfig) }

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width: nil) ⇒ TitleConfig

Returns a new instance of TitleConfig.



13
14
15
# File 'app/components/hakumi_components/skeleton/title_config.rb', line 13

def initialize(width: nil)
  @width = T.let(width, T.nilable(WidthValue))
end

Instance Attribute Details

#widthObject (readonly)

Returns the value of attribute width.



18
19
20
# File 'app/components/hakumi_components/skeleton/title_config.rb', line 18

def width
  @width
end

Class Method Details

.coerce(value) ⇒ Object



21
22
23
24
25
26
27
28
# File 'app/components/hakumi_components/skeleton/title_config.rb', line 21

def self.coerce(value)
  return nil if value == false
  return new if value == true
  return value if value.is_a?(HakumiComponents::Skeleton::TitleConfig)

  width = value[:width]
  new(width: width.is_a?(Integer) || width.is_a?(String) ? width : nil)
end