Class: Plushie::Widget::Text
- Inherits:
-
Object
- Object
- Plushie::Widget::Text
- Defined in:
- lib/plushie/widget/text.rb
Overview
Constant Summary collapse
- PROPS =
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.
Supported property keys for this widget.
%i[content size color font width height line_height align_x align_y wrapping ellipsis shaping style a11y].freeze
Instance Attribute Summary collapse
-
#a11y ⇒ Object
readonly
Returns the value of attribute a11y.
-
#align_x ⇒ Object
readonly
Returns the value of attribute align_x.
-
#align_y ⇒ Object
readonly
Returns the value of attribute align_y.
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#ellipsis ⇒ Object
readonly
Returns the value of attribute ellipsis.
-
#font ⇒ Object
readonly
Returns the value of attribute font.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#line_height ⇒ Object
readonly
Returns the value of attribute line_height.
-
#shaping ⇒ Object
readonly
Returns the value of attribute shaping.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#wrapping ⇒ Object
readonly
Returns the value of attribute wrapping.
Instance Method Summary collapse
-
#build ⇒ Plushie::Node
Build a Node from the current property values.
-
#initialize(id, content = nil, **opts) ⇒ Text
constructor
A new instance of Text.
Constructor Details
#initialize(id, content = nil, **opts) ⇒ Text
Returns a new instance of Text.
19 20 21 22 23 24 |
# File 'lib/plushie/widget/text.rb', line 19 def initialize(id, content = nil, **opts) @id = id.to_s @content = content PROPS.each { |k| instance_variable_set(:"@#{k}", opts[k]) if opts.key?(k) } @content ||= opts[:content] end |
Instance Attribute Details
#a11y ⇒ Object (readonly)
Returns the value of attribute a11y.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def a11y @a11y end |
#align_x ⇒ Object (readonly)
Returns the value of attribute align_x.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def align_x @align_x end |
#align_y ⇒ Object (readonly)
Returns the value of attribute align_y.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def align_y @align_y end |
#color ⇒ Object (readonly)
Returns the value of attribute color.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def color @color end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def content @content end |
#ellipsis ⇒ Object (readonly)
Returns the value of attribute ellipsis.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def ellipsis @ellipsis end |
#font ⇒ Object (readonly)
Returns the value of attribute font.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def font @font end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def height @height end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def id @id end |
#line_height ⇒ Object (readonly)
Returns the value of attribute line_height.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def line_height @line_height end |
#shaping ⇒ Object (readonly)
Returns the value of attribute shaping.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def shaping @shaping end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def size @size end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def style @style end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def width @width end |
#wrapping ⇒ Object (readonly)
Returns the value of attribute wrapping.
1 2 3 |
# File 'lib/plushie/widget/text.rb', line 1 def wrapping @wrapping end |
Instance Method Details
#build ⇒ Plushie::Node
Build a Node from the current property values.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/plushie/widget/text.rb', line 35 def build props = {} Build.put_if(props, :content, @content) Build.put_if(props, :size, @size) Build.put_if(props, :color, @color) Build.put_if(props, :font, @font) Build.put_if(props, :width, @width) Build.put_if(props, :height, @height) Build.put_if(props, :line_height, @line_height) Build.put_if(props, :align_x, @align_x) Build.put_if(props, :align_y, @align_y) Build.put_if(props, :wrapping, @wrapping) Build.put_if(props, :ellipsis, @ellipsis) Build.put_if(props, :shaping, @shaping) Build.put_if(props, :style, @style) Build.put_if(props, :a11y, @a11y) Node.new(id: @id, type: "text", props: props) end |