Class: Tuile::Component::Layout::Percent
- Inherits:
-
Object
- Object
- Tuile::Component::Layout::Percent
- Defined in:
- lib/tuile/component/layout.rb,
sig/tuile.rbs
Overview
A percentage of the space available along a Box's axis — measured
after Box#padding and Box#spacing have come off, so two Percent[50]
children fit exactly rather than overflowing by the gap between them.
add(left, Percent[60])
add(right, Percent[40])
Instance Attribute Summary collapse
-
#percent ⇒ Numeric
readonly
@return — percentage of the available extent,
0..100.
Instance Method Summary collapse
-
#initialize(percent:) ⇒ Percent
constructor
@param
percent— percentage of the available extent,0..100.
Constructor Details
#initialize(percent:) ⇒ Percent
@param percent — percentage of the available extent, 0..100.
54 55 56 57 58 59 60 |
# File 'lib/tuile/component/layout.rb', line 54 def initialize(percent:) unless percent.is_a?(Numeric) && percent.between?(0, 100) raise ArgumentError, "Percent expects a Numeric in 0..100, got #{percent.inspect}" end super end |
Instance Attribute Details
#percent ⇒ Numeric (readonly)
@return — percentage of the available extent, 0..100.
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/tuile/component/layout.rb', line 51 class Percent < Data.define(:percent) # @param percent [Numeric] percentage of the available extent, `0..100`. # @raise [ArgumentError] unless `percent` is a Numeric in `0..100`. def initialize(percent:) unless percent.is_a?(Numeric) && percent.between?(0, 100) raise ArgumentError, "Percent expects a Numeric in 0..100, got #{percent.inspect}" end super end end |