Class: Chamomile::Widgets::Text
- Inherits:
-
Object
- Object
- Chamomile::Widgets::Text
- Defined in:
- lib/chamomile/frame.rb
Overview
Plain text block.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
-
#initialize(content: "") ⇒ Text
constructor
A new instance of Text.
- #render(width: 80, height: 24) ⇒ Object
Constructor Details
#initialize(content: "") ⇒ Text
Returns a new instance of Text.
100 101 102 |
# File 'lib/chamomile/frame.rb', line 100 def initialize(content: "") @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
98 99 100 |
# File 'lib/chamomile/frame.rb', line 98 def content @content end |
Instance Method Details
#render(width: 80, height: 24) ⇒ Object
104 105 106 107 108 |
# File 'lib/chamomile/frame.rb', line 104 def render(width: 80, height: 24) lines = @content.split("\n", -1) lines = lines[0, height] if lines.length > height lines.map { |l| l.length > width ? l[0, width] : l }.join("\n") end |