Class: Chamomile::Layout::Vertical

Inherits:
Base
  • Object
show all
Defined in:
lib/chamomile/layout/vertical.rb

Instance Method Summary collapse

Constructor Details

#initialize(align: :left) ⇒ Vertical

Returns a new instance of Vertical.



6
7
8
9
# File 'lib/chamomile/layout/vertical.rb', line 6

def initialize(align: :left)
  @align    = align
  @children = []
end

Instance Method Details

#add(child) ⇒ Object



11
12
13
14
# File 'lib/chamomile/layout/vertical.rb', line 11

def add(child)
  @children << child
  self
end

#render(width:, height:) ⇒ Object



16
17
18
19
20
# File 'lib/chamomile/layout/vertical.rb', line 16

def render(width:, height:)
  return "" if @children.empty?
  parts = @children.map { |c| c.render(width: width, height: height) }
  Chamomile.vertical(parts, align: @align)
end