Class: Chamomile::Options
- Inherits:
-
Data
- Object
- Data
- Chamomile::Options
- Defined in:
- lib/chamomile/options.rb
Overview
Immutable configuration for a Program run.
Instance Attribute Summary collapse
-
#alt_screen ⇒ Object
readonly
Returns the value of attribute alt_screen.
-
#bracketed_paste ⇒ Object
readonly
Returns the value of attribute bracketed_paste.
-
#catch_panics ⇒ Object
readonly
Returns the value of attribute catch_panics.
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#fps ⇒ Object
readonly
Returns the value of attribute fps.
-
#handle_signals ⇒ Object
readonly
Returns the value of attribute handle_signals.
-
#initial_height ⇒ Object
readonly
Returns the value of attribute initial_height.
-
#initial_width ⇒ Object
readonly
Returns the value of attribute initial_width.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#input_tty ⇒ Object
readonly
Returns the value of attribute input_tty.
-
#mouse ⇒ Object
readonly
Returns the value of attribute mouse.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#report_focus ⇒ Object
readonly
Returns the value of attribute report_focus.
-
#without_renderer ⇒ Object
readonly
Returns the value of attribute without_renderer.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#alt_screen ⇒ Object (readonly)
Returns the value of attribute alt_screen
7 8 9 |
# File 'lib/chamomile/options.rb', line 7 def alt_screen @alt_screen end |
#bracketed_paste ⇒ Object (readonly)
Returns the value of attribute bracketed_paste
7 8 9 |
# File 'lib/chamomile/options.rb', line 7 def bracketed_paste @bracketed_paste end |
#catch_panics ⇒ Object (readonly)
Returns the value of attribute catch_panics
7 8 9 |
# File 'lib/chamomile/options.rb', line 7 def catch_panics @catch_panics end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter
7 8 9 |
# File 'lib/chamomile/options.rb', line 7 def filter @filter end |
#fps ⇒ Object (readonly)
Returns the value of attribute fps
7 8 9 |
# File 'lib/chamomile/options.rb', line 7 def fps @fps end |
#handle_signals ⇒ Object (readonly)
Returns the value of attribute handle_signals
7 8 9 |
# File 'lib/chamomile/options.rb', line 7 def handle_signals @handle_signals end |
#initial_height ⇒ Object (readonly)
Returns the value of attribute initial_height
7 8 9 |
# File 'lib/chamomile/options.rb', line 7 def initial_height @initial_height end |
#initial_width ⇒ Object (readonly)
Returns the value of attribute initial_width
7 8 9 |
# File 'lib/chamomile/options.rb', line 7 def initial_width @initial_width end |
#input ⇒ Object (readonly)
Returns the value of attribute input
7 8 9 |
# File 'lib/chamomile/options.rb', line 7 def input @input end |
#input_tty ⇒ Object (readonly)
Returns the value of attribute input_tty
7 8 9 |
# File 'lib/chamomile/options.rb', line 7 def input_tty @input_tty end |
#mouse ⇒ Object (readonly)
Returns the value of attribute mouse
7 8 9 |
# File 'lib/chamomile/options.rb', line 7 def mouse @mouse end |
#output ⇒ Object (readonly)
Returns the value of attribute output
7 8 9 |
# File 'lib/chamomile/options.rb', line 7 def output @output end |
#report_focus ⇒ Object (readonly)
Returns the value of attribute report_focus
7 8 9 |
# File 'lib/chamomile/options.rb', line 7 def report_focus @report_focus end |
#without_renderer ⇒ Object (readonly)
Returns the value of attribute without_renderer
7 8 9 |
# File 'lib/chamomile/options.rb', line 7 def without_renderer @without_renderer end |
Class Method Details
.default(**overrides) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/chamomile/options.rb', line 23 def self.default(**overrides) opts = new(alt_screen: true, mouse: :none, report_focus: false, bracketed_paste: true, fps: 60, input: $stdin, output: $stdout, filter: nil, catch_panics: true, handle_signals: true, input_tty: false, without_renderer: false, initial_width: nil, initial_height: nil, **overrides) opts.validate opts end |
Instance Method Details
#validate ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/chamomile/options.rb', line 43 def validate unless VALID_MOUSE_MODES.include?(mouse) raise ArgumentError, "invalid mouse mode: #{mouse.inspect} (valid: #{VALID_MOUSE_MODES.join(", ")})" end unless fps.is_a?(Numeric) && fps >= 0 raise ArgumentError, "fps must be a non-negative number, got: #{fps.inspect}" end raise ArgumentError, "filter must respond to #call, got: #{filter.class}" if filter && !filter.respond_to?(:call) end |