Class: Tuile::Component::Layout::Expand
- Inherits:
-
Object
- Object
- Tuile::Component::Layout::Expand
- Defined in:
- lib/tuile/component/layout.rb,
sig/tuile.rbs
Overview
A share of whatever a Box has left once its Fixed and Percent
children have taken theirs, split between the Expand children in
proportion to their weights:
add(header, Fixed[1])
add(body, Expand[2]) # gets twice…
add(side, Expand[1]) # …what this one gets
Main axis only — Box#add rejects one passed as cross:, where a child
has no siblings to compete with and so nothing for a weight to mean.
Instance Attribute Summary collapse
-
#weight ⇒ Integer
readonly
@return — relative share of the leftover space.
Instance Method Summary collapse
-
#initialize(weight:) ⇒ Expand
constructor
@param
weight— relative share;>= 1.
Constructor Details
#initialize(weight:) ⇒ Expand
@param weight — relative share; >= 1.
79 80 81 82 83 84 85 |
# File 'lib/tuile/component/layout.rb', line 79 def initialize(weight:) unless weight.is_a?(Integer) && weight.positive? raise ArgumentError, "Expand expects a positive Integer weight, got #{weight.inspect}" end super end |
Instance Attribute Details
#weight ⇒ Integer (readonly)
@return — relative share of the leftover space.
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/tuile/component/layout.rb', line 76 class Expand < Data.define(:weight) # @param weight [Integer] relative share; `>= 1`. # @raise [ArgumentError] unless `weight` is a positive Integer. def initialize(weight:) unless weight.is_a?(Integer) && weight.positive? raise ArgumentError, "Expand expects a positive Integer weight, got #{weight.inspect}" end super end end |