Class: Tabby::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/tabby/base.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



23
24
25
# File 'lib/tabby/base.rb', line 23

def initialize
  @commands = []
end

Class Attribute Details

._basedirObject (readonly)

Returns the value of attribute _basedir.



3
4
5
# File 'lib/tabby/base.rb', line 3

def _basedir
  @_basedir
end

Instance Attribute Details

#commandsObject

List of commands for the current tab to execute.



15
16
17
# File 'lib/tabby/base.rb', line 15

def commands
  @commands
end

#templateObject

Rendered AppleScript source to be saved to a tempfile.



21
22
23
# File 'lib/tabby/base.rb', line 21

def template
  @template
end

#titleObject

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

#basedirObject

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

#callObject

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