Class: Prompts::Content
- Inherits:
-
Object
- Object
- Prompts::Content
- Defined in:
- lib/prompts/content.rb
Instance Attribute Summary collapse
-
#slots ⇒ Object
readonly
Returns the value of attribute slots.
Instance Method Summary collapse
- #box(padded: false, border_color: nil) {|box| ... } ⇒ Object
- #gap ⇒ Object
-
#initialize(width: MAX_WIDTH) ⇒ Content
constructor
A new instance of Content.
- #paragraph(text) ⇒ Object
- #prepend(*lines) ⇒ Object
- #render ⇒ Object
- #reset! ⇒ Object
Constructor Details
Instance Attribute Details
#slots ⇒ Object (readonly)
Returns the value of attribute slots.
5 6 7 |
# File 'lib/prompts/content.rb', line 5 def slots @slots end |
Instance Method Details
#box(padded: false, border_color: nil) {|box| ... } ⇒ Object
24 25 26 27 28 29 |
# File 'lib/prompts/content.rb', line 24 def box(padded: false, border_color: nil, &block) box = Box.new(width: @width, padded: padded, border_color: border_color) yield(box) @slots.concat box.lines self end |
#gap ⇒ Object
19 20 21 22 |
# File 'lib/prompts/content.rb', line 19 def gap @slots << SPACE self end |
#paragraph(text) ⇒ Object
13 14 15 16 17 |
# File 'lib/prompts/content.rb', line 13 def paragraph(text) paragraph = Paragraph.new(text, width: @width) @slots.concat paragraph.lines self end |
#prepend(*lines) ⇒ Object
40 41 42 |
# File 'lib/prompts/content.rb', line 40 def prepend(*lines) @slots.unshift(*lines) end |
#render ⇒ Object
31 32 33 34 |
# File 'lib/prompts/content.rb', line 31 def render clear_screen render_frame end |
#reset! ⇒ Object
36 37 38 |
# File 'lib/prompts/content.rb', line 36 def reset! @slots = @frame_stack.first.dup end |