Module: Plushie::Type::Length
- Defined in:
- lib/plushie/type/length.rb
Overview
Size value for the width and height props on most widgets.
Accepts :fill, :shrink, [:fill_portion, n], or a numeric pixel value. Maps to iced's Length enum.
Class Method Summary collapse
-
.encode(value) ⇒ String, ...
Encode a length value for the wire format.
Class Method Details
.encode(value) ⇒ String, ...
Encode a length value for the wire format.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/plushie/type/length.rb', line 22 def encode(value) case value when :fill then "fill" when :shrink then "shrink" when Array if value.length == 2 && value[0] == :fill_portion {fill_portion: value[1]} else raise ArgumentError, "invalid length array: #{value.inspect}" end when Numeric raise ArgumentError, "length must be non-negative, got: #{value}" if value < 0 value else raise ArgumentError, "invalid length: #{value.inspect}. Use :fill, :shrink, [:fill_portion, n], or a number" end end |