Class: RemoteRuby::TextModeBuilder
- Inherits:
-
Object
- Object
- RemoteRuby::TextModeBuilder
- Defined in:
- lib/remote_ruby/text_mode_builder.rb
Overview
Wraps the connection adapter in a text mode adapter if text mode is enabled.
Instance Attribute Summary collapse
-
#err_tty ⇒ Object
readonly
Returns the value of attribute err_tty.
-
#out_tty ⇒ Object
readonly
Returns the value of attribute out_tty.
-
#text_mode ⇒ Object
readonly
Returns the value of attribute text_mode.
Instance Method Summary collapse
- #build(adapter) ⇒ Object
-
#initialize(params:, out_tty: true, err_tty: true) ⇒ TextModeBuilder
constructor
A new instance of TextModeBuilder.
Constructor Details
#initialize(params:, out_tty: true, err_tty: true) ⇒ TextModeBuilder
Returns a new instance of TextModeBuilder.
8 9 10 11 12 |
# File 'lib/remote_ruby/text_mode_builder.rb', line 8 def initialize(params:, out_tty: true, err_tty: true) @out_tty = out_tty @err_tty = err_tty @text_mode = params.delete(:text_mode) || false end |
Instance Attribute Details
#err_tty ⇒ Object (readonly)
Returns the value of attribute err_tty.
6 7 8 |
# File 'lib/remote_ruby/text_mode_builder.rb', line 6 def err_tty @err_tty end |
#out_tty ⇒ Object (readonly)
Returns the value of attribute out_tty.
6 7 8 |
# File 'lib/remote_ruby/text_mode_builder.rb', line 6 def out_tty @out_tty end |
#text_mode ⇒ Object (readonly)
Returns the value of attribute text_mode.
6 7 8 |
# File 'lib/remote_ruby/text_mode_builder.rb', line 6 def text_mode @text_mode end |
Instance Method Details
#build(adapter) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/remote_ruby/text_mode_builder.rb', line 14 def build(adapter) return adapter unless text_mode cache_mode = adapter.is_a? CacheAdapter tm_params = text_mode_params(adapter, cache_mode, out_tty, err_tty) return adapter unless tm_params[:stdout_prefix] || tm_params[:stderr_prefix] ::RemoteRuby::TextModeAdapter.new(adapter, **tm_params) end |