Class: Plushie::Type::StyleMap::Spec
- Inherits:
-
Data
- Object
- Data
- Plushie::Type::StyleMap::Spec
- Defined in:
- lib/plushie/type/style_map.rb
Overview
Immutable spec; use #with to create modified copies.
Instance Attribute Summary collapse
-
#background ⇒ Object
readonly
Returns the value of attribute background.
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#border ⇒ Object
readonly
Returns the value of attribute border.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#focused ⇒ Object
readonly
Returns the value of attribute focused.
-
#hovered ⇒ Object
readonly
Returns the value of attribute hovered.
-
#pressed ⇒ Object
readonly
Returns the value of attribute pressed.
-
#shadow ⇒ Object
readonly
Returns the value of attribute shadow.
-
#text_color ⇒ Object
readonly
Returns the value of attribute text_color.
Instance Method Summary collapse
-
#initialize(base: nil, background: nil, text_color: nil, border: nil, shadow: nil, hovered: nil, pressed: nil, disabled: nil, focused: nil) ⇒ Spec
constructor
A new instance of Spec.
-
#to_wire ⇒ Hash
Wire-ready map with nil fields stripped.
-
#with(**changes) ⇒ Object
Returns a copy with the given fields updated.
Constructor Details
#initialize(base: nil, background: nil, text_color: nil, border: nil, shadow: nil, hovered: nil, pressed: nil, disabled: nil, focused: nil) ⇒ Spec
Returns a new instance of Spec.
46 47 48 49 50 |
# File 'lib/plushie/type/style_map.rb', line 46 def initialize(base: nil, background: nil, text_color: nil, border: nil, shadow: nil, hovered: nil, pressed: nil, disabled: nil, focused: nil) super end |
Instance Attribute Details
#background ⇒ Object (readonly)
Returns the value of attribute background
44 45 46 |
# File 'lib/plushie/type/style_map.rb', line 44 def background @background end |
#base ⇒ Object (readonly)
Returns the value of attribute base
44 45 46 |
# File 'lib/plushie/type/style_map.rb', line 44 def base @base end |
#border ⇒ Object (readonly)
Returns the value of attribute border
44 45 46 |
# File 'lib/plushie/type/style_map.rb', line 44 def border @border end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled
44 45 46 |
# File 'lib/plushie/type/style_map.rb', line 44 def disabled @disabled end |
#focused ⇒ Object (readonly)
Returns the value of attribute focused
44 45 46 |
# File 'lib/plushie/type/style_map.rb', line 44 def focused @focused end |
#hovered ⇒ Object (readonly)
Returns the value of attribute hovered
44 45 46 |
# File 'lib/plushie/type/style_map.rb', line 44 def hovered @hovered end |
#pressed ⇒ Object (readonly)
Returns the value of attribute pressed
44 45 46 |
# File 'lib/plushie/type/style_map.rb', line 44 def pressed @pressed end |
#shadow ⇒ Object (readonly)
Returns the value of attribute shadow
44 45 46 |
# File 'lib/plushie/type/style_map.rb', line 44 def shadow @shadow end |
#text_color ⇒ Object (readonly)
Returns the value of attribute text_color
44 45 46 |
# File 'lib/plushie/type/style_map.rb', line 44 def text_color @text_color end |
Instance Method Details
#to_wire ⇒ Hash
Returns wire-ready map with nil fields stripped.
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/plushie/type/style_map.rb', line 58 def to_wire h = {} h[:base] = base.to_s if base h[:background] = background if background h[:text_color] = text_color if text_color h[:border] = Border.encode(border) if border h[:shadow] = Shadow.encode(shadow) if shadow h[:hovered] = encode_state(hovered) if hovered h[:pressed] = encode_state(pressed) if pressed h[:disabled] = encode_state(disabled) if disabled h[:focused] = encode_state(focused) if focused h end |
#with(**changes) ⇒ Object
Returns a copy with the given fields updated.
53 54 55 |
# File 'lib/plushie/type/style_map.rb', line 53 def with(**changes) self.class.new(**to_h.merge(changes)) end |