Class: NattyUI::Wrapper::Section
- Defined in:
- lib/natty-ui/wrapper/section.rb
Overview
Visual Element to keep text lines together.
A section can contain other elements and sections.
Instance Method Summary collapse
-
#available_width ⇒ Integer
Available columns count within the section.
-
#print(*args, **options) ⇒ Section
Print given arguments into the section.
-
#puts(*args, **options) ⇒ Section
Print given arguments line-wise into the section.
-
#space(lines = 1) ⇒ Section
Add at least one empty line.
-
#temporary {|Section| ... } ⇒ Object
Resets the part of the screen written below the current output line when the given block ended.
Instance Method Details
#available_width ⇒ Integer
Returns available columns count within the section.
31 32 33 34 |
# File 'lib/natty-ui/wrapper/section.rb', line 31 def available_width @available_width ||= @parent.available_width - @prefix_width - @suffix_width end |
#print(*args, **options) ⇒ Section
Print given arguments into the section.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/natty-ui/wrapper/section.rb', line 60 def print(*args, **) return self if @status @parent.print( *args, **.merge!( prefix: "#{@prefix}#{[:prefix]}", prefix_width: @prefix_width + [:prefix_width].to_i, suffix: "#{[:suffix]}#{@suffix}", suffix_width: @suffix_width + [:suffix_width].to_i ) ) self end |
#puts(*args, **options) ⇒ Section
Print given arguments line-wise into the section.
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/natty-ui/wrapper/section.rb', line 41 def puts(*args, **) return self if @status @parent.puts( *args, **.merge!( prefix: "#{@prefix}#{[:prefix]}", prefix_width: @prefix_width + [:prefix_width].to_i, suffix: "#{[:suffix]}#{@suffix}", suffix_width: @suffix_width + [:suffix_width].to_i ) ) self end |
#space(lines = 1) ⇒ Section
Add at least one empty line
78 |
# File 'lib/natty-ui/wrapper/section.rb', line 78 def space(lines = 1) = puts("\n" * [1, lines.to_i].max) |
#temporary {|Section| ... } ⇒ Object
Note:
The screen manipulation is only available in ANSI mode see NattyUI::Wrapper#ansi?
Resets the part of the screen written below the current output line when the given block ended.
93 |
# File 'lib/natty-ui/wrapper/section.rb', line 93 def temporary = block_given? ? yield(self) : self |