Class: TermDump::BasicTerminal
- Inherits:
-
Object
- Object
- TermDump::BasicTerminal
- Includes:
- TerminalHelper
- Defined in:
- lib/termdump/terminal/base/base.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#configure(configure_key) ⇒ Object
Get user defined value/configure value/default value with a configure item.
-
#exec(cwd, cmd) ⇒ Object
run command in current window
cwdis the directory the command executed incmdif the cmd is nil, don’t need to execute it; else execute the cmd. -
#initialize(config) ⇒ BasicTerminal
constructor
A new instance of BasicTerminal.
-
#window(name, cwd, cmd) ⇒ Object
open a new window of this terminal automatically and focus on
nameis the name of new windowcwdis the directory the command executed incmdif the cmd is nil, don’t need to execute it; else execute the cmd.
Methods included from TerminalHelper
#convert_key_sequence, #escape
Constructor Details
#initialize(config) ⇒ BasicTerminal
Returns a new instance of BasicTerminal.
7 8 9 10 11 |
# File 'lib/termdump/terminal/base/base.rb', line 7 def initialize config @user_defined_config = config @config = {} @default_config = {} end |
Instance Method Details
#configure(configure_key) ⇒ Object
Get user defined value/configure value/default value with a configure item. Raise keyError if value not found.
15 16 17 18 19 |
# File 'lib/termdump/terminal/base/base.rb', line 15 def configure configure_key @user_defined_config.fetch(configure_key) {|key_in_config| @config.fetch(key_in_config) {|default_key| @default_config.fetch(default_key)}} end |
#exec(cwd, cmd) ⇒ Object
run command in current window cwd is the directory the command executed in cmd if the cmd is nil, don’t need to execute it; else execute the cmd
24 25 26 27 |
# File 'lib/termdump/terminal/base/base.rb', line 24 def exec cwd, cmd raise NotImplementedError.new( "exec should be implemented to execute cmd on current window") end |
#window(name, cwd, cmd) ⇒ Object
open a new window of this terminal automatically and focus on name is the name of new window cwd is the directory the command executed in cmd if the cmd is nil, don’t need to execute it; else execute the cmd
33 34 35 36 |
# File 'lib/termdump/terminal/base/base.rb', line 33 def window name, cwd, cmd raise NotImplementedError.new( "window should be implemented to open new window") end |