Class: Tabby::Base
- Inherits:
-
Object
- Object
- Tabby::Base
- Defined in:
- lib/tabby/base.rb
Class Attribute Summary collapse
-
._basedir ⇒ Object
readonly
Returns the value of attribute _basedir.
Instance Attribute Summary collapse
-
#commands ⇒ Object
List of commands for the current tab to execute.
-
#template ⇒ Object
Rendered AppleScript source to be saved to a tempfile.
-
#title ⇒ Object
Title of the current tab being created.
Class Method Summary collapse
-
.basedir(dir) ⇒ Object
Sets the project root directory.
Instance Method Summary collapse
-
#basedir ⇒ Object
Project’s base directory.
-
#call ⇒ Object
Call each instance method and create a tab for each one.
-
#exec(command) ⇒ Object
Queue a command to be executed when the tab gets created.
-
#initialize ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
23 24 25 |
# File 'lib/tabby/base.rb', line 23 def initialize @commands = [] end |
Class Attribute Details
._basedir ⇒ Object (readonly)
Returns the value of attribute _basedir.
3 4 5 |
# File 'lib/tabby/base.rb', line 3 def _basedir @_basedir end |
Instance Attribute Details
#commands ⇒ Object
List of commands for the current tab to execute.
15 16 17 |
# File 'lib/tabby/base.rb', line 15 def commands @commands end |
#template ⇒ Object
Rendered AppleScript source to be saved to a tempfile.
21 22 23 |
# File 'lib/tabby/base.rb', line 21 def template @template end |
#title ⇒ Object
Title of the current tab being created.
18 19 20 |
# File 'lib/tabby/base.rb', line 18 def title @title end |
Class Method Details
.basedir(dir) ⇒ Object
Sets the project root directory.
Parameters:
dir Project's root directory path
10 11 12 |
# File 'lib/tabby/base.rb', line 10 def self.basedir(dir) @_basedir = dir end |
Instance Method Details
#basedir ⇒ Object
Project’s base directory. Each tab cd
‘s into this directory before executing commands.
52 53 54 |
# File 'lib/tabby/base.rb', line 52 def basedir self.class._basedir end |
#call ⇒ Object
Call each instance method and create a tab for each one. Method names become tab titles, with underscores replaced with spaces.
40 41 42 43 44 45 46 47 |
# File 'lib/tabby/base.rb', line 40 def call self.class.instance_methods(false).each do |method| @commands = [] @title = method send(method) create_tab end end |
#exec(command) ⇒ Object
Queue a command to be executed when the tab gets created.
Parameters:
command bash/zsh/etc command to be executed
32 33 34 |
# File 'lib/tabby/base.rb', line 32 def exec(command) @commands << %{write text "#{command}"} end |