Class: TermDump::BasicTerminal
- Inherits:
-
Object
- Object
- TermDump::BasicTerminal
- Includes:
- TerminalHelper
- Defined in:
- lib/termdump/terminal/base/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#delay ⇒ Object
writeonly
Sets the attribute delay.
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.
-
#wait_for_launching ⇒ Object
wait until shell/terminal launched, so that we can do something in them.
-
#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.
8 9 10 11 12 13 14 |
# File 'lib/termdump/terminal/base/base.rb', line 8 def initialize config @user_defined_config = config @config = {} @default_config = {} @delay = 0.5 # delay for 0.5 second end |
Instance Attribute Details
#delay=(value) ⇒ Object (writeonly)
Sets the attribute delay
7 8 9 |
# File 'lib/termdump/terminal/base/base.rb', line 7 def delay=(value) @delay = value 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.
18 19 20 21 22 23 24 |
# File 'lib/termdump/terminal/base/base.rb', line 18 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
34 35 36 37 |
# File 'lib/termdump/terminal/base/base.rb', line 34 def exec cwd, cmd raise NotImplementedError.new( "exec should be implemented to execute cmd on current window") end |
#wait_for_launching ⇒ Object
wait until shell/terminal launched, so that we can do something in them
27 28 29 |
# File 'lib/termdump/terminal/base/base.rb', line 27 def wait_for_launching sleep @delay 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
43 44 45 46 |
# File 'lib/termdump/terminal/base/base.rb', line 43 def window name, cwd, cmd raise NotImplementedError.new( "window should be implemented to open new window") end |