Class: HakumiComponents::Table::FixedOffset

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

Constant Summary collapse

SIDES =
T.let(%i[left right].freeze, T::Array[Symbol])

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(side:, offset:) ⇒ FixedOffset

Returns a new instance of FixedOffset.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
# File 'app/components/hakumi_components/table/fixed_offset.rb', line 12

def initialize(side:, offset:)
  raise ArgumentError, "Invalid fixed side: #{side.inspect}" unless SIDES.include?(side)

  @side = T.let(side, Symbol)
  @offset = T.let(offset, Float)
end

Instance Attribute Details

#offsetObject (readonly)

Returns the value of attribute offset.



23
24
25
# File 'app/components/hakumi_components/table/fixed_offset.rb', line 23

def offset
  @offset
end

#sideObject (readonly)

Returns the value of attribute side.



20
21
22
# File 'app/components/hakumi_components/table/fixed_offset.rb', line 20

def side
  @side
end

Instance Method Details

#[](name) ⇒ Object



26
27
28
29
30
31
32
33
# File 'app/components/hakumi_components/table/fixed_offset.rb', line 26

def [](name)
  case name
  when :side then @side
  when :offset then @offset
  else
    raise ArgumentError, "Unknown fixed offset key: #{name.inspect}"
  end
end