Class: Chamomile::Layout::Text
- Defined in:
- lib/chamomile/layout/text.rb
Instance Method Summary collapse
-
#initialize(content, bold: false, italic: false, color: nil, dim: false, width: nil, align: :left) ⇒ Text
constructor
A new instance of Text.
- #render(width:, height:) ⇒ Object
Constructor Details
#initialize(content, bold: false, italic: false, color: nil, dim: false, width: nil, align: :left) ⇒ Text
Returns a new instance of Text.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/chamomile/layout/text.rb', line 6 def initialize(content, bold: false, italic: false, color: nil, dim: false, width: nil, align: :left) @content = content.to_s @bold = bold @italic = italic @color = color @dim = dim @width = width @align = align end |
Instance Method Details
#render(width:, height:) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/chamomile/layout/text.rb', line 17 def render(width:, height:) style = Chamomile::Style.new style = style.bold if @bold style = style.italic if @italic style = style.faint if @dim style = style.foreground(@color) if @color style = style.width(@width || width) style = style.align_horizontal(@align) style.render(@content) end |