Class: Tabby::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/tabby.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.



26
27
28
# File 'lib/tabby.rb', line 26

def initialize
  @commands = []
end

Class Attribute Details

._basedirObject (readonly)

Returns the value of attribute _basedir.



6
7
8
# File 'lib/tabby.rb', line 6

def _basedir
  @_basedir
end

Instance Attribute Details

#commandsObject

List of commands for the current tab to execute.



18
19
20
# File 'lib/tabby.rb', line 18

def commands
  @commands
end

#templateObject

Rendered AppleScript source to be saved to a tempfile.



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

def template
  @template
end

#titleObject

Title of the current tab being created.



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

def title
  @title
end

Class Method Details

.basedir(dir) ⇒ Object

Sets the project root directory.

Parameters:

dir  Project's root directory path


13
14
15
# File 'lib/tabby.rb', line 13

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.



55
56
57
# File 'lib/tabby.rb', line 55

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.



43
44
45
46
47
48
49
50
# File 'lib/tabby.rb', line 43

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


35
36
37
# File 'lib/tabby.rb', line 35

def exec(command)
  @commands << %{write text "#{command}"}
end