Class: TTY::Command::Window::WindowOptions
- Inherits:
-
Struct
- Object
- Struct
- TTY::Command::Window::WindowOptions
- Defined in:
- lib/tty/command/window/window_options.rb
Overview
Immutable, validated configuration for a single windowed run.
Built from the raw options hash the user passed to run_windowed
by WindowOptions.build. Runner and Block consume named accessors on this
object instead of dereferencing symbol keys, so the option
contract is explicit.
Struct.new(..., keyword_init: true) is used (rather than
Data.define) because Data.define ships in Ruby 3.2 and the
gemspec's required_ruby_version floor is 3.1. Instances are
frozen in WindowOptions.build for immutability.
Instance Attribute Summary collapse
-
#capture ⇒ Object
Returns the value of attribute capture.
-
#capture_max_bytes ⇒ Object
Returns the value of attribute capture_max_bytes.
-
#dump_lines ⇒ Object
Returns the value of attribute dump_lines.
-
#interactive ⇒ Object
Returns the value of attribute interactive.
-
#lines ⇒ Object
Returns the value of attribute lines.
-
#on_exit ⇒ Object
Returns the value of attribute on_exit.
-
#output_log ⇒ Object
Returns the value of attribute output_log.
-
#scrollback ⇒ Object
Returns the value of attribute scrollback.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#capture ⇒ Object
Returns the value of attribute capture
17 18 19 |
# File 'lib/tty/command/window/window_options.rb', line 17 def capture @capture end |
#capture_max_bytes ⇒ Object
Returns the value of attribute capture_max_bytes
17 18 19 |
# File 'lib/tty/command/window/window_options.rb', line 17 def capture_max_bytes @capture_max_bytes end |
#dump_lines ⇒ Object
Returns the value of attribute dump_lines
17 18 19 |
# File 'lib/tty/command/window/window_options.rb', line 17 def dump_lines @dump_lines end |
#interactive ⇒ Object
Returns the value of attribute interactive
17 18 19 |
# File 'lib/tty/command/window/window_options.rb', line 17 def interactive @interactive end |
#lines ⇒ Object
Returns the value of attribute lines
17 18 19 |
# File 'lib/tty/command/window/window_options.rb', line 17 def lines @lines end |
#on_exit ⇒ Object
Returns the value of attribute on_exit
17 18 19 |
# File 'lib/tty/command/window/window_options.rb', line 17 def on_exit @on_exit end |
#output_log ⇒ Object
Returns the value of attribute output_log
17 18 19 |
# File 'lib/tty/command/window/window_options.rb', line 17 def output_log @output_log end |
#scrollback ⇒ Object
Returns the value of attribute scrollback
17 18 19 |
# File 'lib/tty/command/window/window_options.rb', line 17 def scrollback @scrollback end |
#title ⇒ Object
Returns the value of attribute title
17 18 19 |
# File 'lib/tty/command/window/window_options.rb', line 17 def title @title end |
Class Method Details
.build(window_options, cmd) ⇒ WindowOptions
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/tty/command/window/window_options.rb', line 26 def self.build(, cmd) lines = Integer(.fetch(:lines, DEFAULT_LINES)) raise ArgumentError, "lines must be >= 1" if lines < 1 on_exit = validated_enum(, :on_exit, ON_EXIT_MODES, :freeze) capture = validated_enum(, :capture, CAPTURE_MODES, :raw) capture_max_bytes = .fetch(:capture_max_bytes, DEFAULT_CAPTURE_MAX_BYTES) unless capture_max_bytes.nil? capture_max_bytes = Integer(capture_max_bytes) raise ArgumentError, "capture_max_bytes must be >= 1 or nil" if capture_max_bytes < 1 end dump_lines = .fetch(:dump_lines, nil) unless dump_lines.nil? dump_lines = Integer(dump_lines) raise ArgumentError, "dump_lines must be >= 1 or nil" if dump_lines < 1 end Window.validate_on_unavailable!() title = .fetch(:title, nil) title = cmd.to_command if title.nil? new( lines: lines, title: title, on_exit: on_exit, capture: capture, capture_max_bytes: capture_max_bytes, scrollback: Integer(.fetch(:scrollback, DEFAULT_SCROLLBACK)), output_log: [:output_log], interactive: [:interactive] == true, dump_lines: dump_lines ).freeze end |
Instance Method Details
#capture_screen? ⇒ Boolean
77 78 79 |
# File 'lib/tty/command/window/window_options.rb', line 77 def capture_screen? capture == :screen end |
#interactive? ⇒ Boolean
73 74 75 |
# File 'lib/tty/command/window/window_options.rb', line 73 def interactive? interactive end |