Module: Plushie::Type::Border
- Defined in:
- lib/plushie/type/border.rb
Overview
Border specification for container and widget styling.
A border has color, width, and radius (uniform or per-corner).
Defined Under Namespace
Classes: Spec
Constant Summary collapse
- FIELD_KEYS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Recognized field keys for border specs.
%i[color width rounded radius].freeze
Class Method Summary collapse
-
.encode(value) ⇒ Hash?
Encode a border value for the wire protocol.
-
.from_opts(opts) ⇒ Spec
Construct from keyword options.
-
.new ⇒ Spec
Create a new border with defaults (no color, zero width, zero radius).
Class Method Details
.encode(value) ⇒ Hash?
Encode a border value for the wire protocol.
94 95 96 97 98 99 100 101 |
# File 'lib/plushie/type/border.rb', line 94 def encode(value) case value when Spec then value.to_wire when Hash then value when nil then nil else raise ArgumentError, "invalid border: #{value.inspect}" end end |
.from_opts(opts) ⇒ Spec
Construct from keyword options.
82 83 84 85 86 87 88 89 |
# File 'lib/plushie/type/border.rb', line 82 def from_opts(opts) spec = Spec.new spec = spec.with(color: Color.cast(opts[:color])) if opts[:color] spec = spec.with(width: opts[:width]) if opts[:width] spec = spec.with(radius: opts[:rounded]) if opts[:rounded] spec = spec.with(radius: opts[:radius]) if opts[:radius] spec end |