Class: Plushie::Widget::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/plushie/widget/container.rb

Overview

Single-child container widget with alignment and styling.

Examples:

Container.new("box").center_x.push(Text.new("msg", "Hello")).build

Instance Method Summary collapse

Instance Method Details

#center_x(width = :fill) ⇒ Object

Return a copy with horizontal centering enabled.



19
20
21
22
23
24
# File 'lib/plushie/widget/container.rb', line 19

def center_x(width = :fill)
  dup.tap do |c|
    c.instance_variable_set(:@width, width)
    c.instance_variable_set(:@align_x, :center)
  end
end

#center_y(height = :fill) ⇒ Object

Return a copy with vertical centering enabled.



27
28
29
30
31
32
# File 'lib/plushie/widget/container.rb', line 27

def center_y(height = :fill)
  dup.tap do |c|
    c.instance_variable_set(:@height, height)
    c.instance_variable_set(:@align_y, :center)
  end
end