Class: Rich::ConsoleOptions
- Inherits:
-
Object
- Object
- Rich::ConsoleOptions
- Defined in:
- lib/rich/console.rb
Overview
Console rendering options
Instance Attribute Summary collapse
-
#encoding ⇒ String
readonly
Output encoding.
-
#height ⇒ Integer?
readonly
Height for rendering.
-
#highlight ⇒ Boolean
readonly
Enable highlighting.
-
#is_terminal ⇒ Boolean
readonly
Terminal output.
-
#legacy_windows ⇒ Boolean
readonly
Legacy Windows console mode.
-
#markup ⇒ Boolean
readonly
Enable markup.
-
#max_width ⇒ Integer
readonly
Maximum width for rendering.
-
#min_width ⇒ Integer
readonly
Minimum width for rendering.
-
#no_wrap ⇒ Boolean
readonly
No wrapping.
Instance Method Summary collapse
-
#initialize(min_width: 1, max_width: 80, height: nil, legacy_windows: false, encoding: "utf-8", is_terminal: true, highlight: true, markup: true, no_wrap: false) ⇒ ConsoleOptions
constructor
A new instance of ConsoleOptions.
-
#update(**kwargs) ⇒ ConsoleOptions
Update options, returning a new instance.
-
#update_width(width) ⇒ ConsoleOptions
Update width.
Constructor Details
#initialize(min_width: 1, max_width: 80, height: nil, legacy_windows: false, encoding: "utf-8", is_terminal: true, highlight: true, markup: true, no_wrap: false) ⇒ ConsoleOptions
Returns a new instance of ConsoleOptions.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rich/console.rb', line 43 def initialize( min_width: 1, max_width: 80, height: nil, legacy_windows: false, encoding: "utf-8", is_terminal: true, highlight: true, markup: true, no_wrap: false ) @min_width = min_width @max_width = max_width @height = height @legacy_windows = legacy_windows @encoding = encoding @is_terminal = is_terminal @highlight = highlight @markup = markup @no_wrap = no_wrap freeze end |
Instance Attribute Details
#encoding ⇒ String (readonly)
Returns Output encoding.
29 30 31 |
# File 'lib/rich/console.rb', line 29 def encoding @encoding end |
#height ⇒ Integer? (readonly)
Returns Height for rendering.
23 24 25 |
# File 'lib/rich/console.rb', line 23 def height @height end |
#highlight ⇒ Boolean (readonly)
Returns Enable highlighting.
35 36 37 |
# File 'lib/rich/console.rb', line 35 def highlight @highlight end |
#is_terminal ⇒ Boolean (readonly)
Returns Terminal output.
32 33 34 |
# File 'lib/rich/console.rb', line 32 def is_terminal @is_terminal end |
#legacy_windows ⇒ Boolean (readonly)
Returns Legacy Windows console mode.
26 27 28 |
# File 'lib/rich/console.rb', line 26 def legacy_windows @legacy_windows end |
#markup ⇒ Boolean (readonly)
Returns Enable markup.
38 39 40 |
# File 'lib/rich/console.rb', line 38 def markup @markup end |
#max_width ⇒ Integer (readonly)
Returns Maximum width for rendering.
20 21 22 |
# File 'lib/rich/console.rb', line 20 def max_width @max_width end |
#min_width ⇒ Integer (readonly)
Returns Minimum width for rendering.
17 18 19 |
# File 'lib/rich/console.rb', line 17 def min_width @min_width end |
#no_wrap ⇒ Boolean (readonly)
Returns No wrapping.
41 42 43 |
# File 'lib/rich/console.rb', line 41 def no_wrap @no_wrap end |
Instance Method Details
#update(**kwargs) ⇒ ConsoleOptions
Update options, returning a new instance
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rich/console.rb', line 68 def update(**kwargs) ConsoleOptions.new( min_width: kwargs.fetch(:min_width, @min_width), max_width: kwargs.fetch(:max_width, @max_width), height: kwargs.fetch(:height, @height), legacy_windows: kwargs.fetch(:legacy_windows, @legacy_windows), encoding: kwargs.fetch(:encoding, @encoding), is_terminal: kwargs.fetch(:is_terminal, @is_terminal), highlight: kwargs.fetch(:highlight, @highlight), markup: kwargs.fetch(:markup, @markup), no_wrap: kwargs.fetch(:no_wrap, @no_wrap) ) end |
#update_width(width) ⇒ ConsoleOptions
Update width
85 86 87 |
# File 'lib/rich/console.rb', line 85 def update_width(width) update(min_width: width, max_width: width) end |