Class: Dutchman::GhostWriter::AppleScript::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/dutchman/ghost_writer/apple_script/command.rb

Overview

The Command class executes the provided AppleScript.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container, applescript) ⇒ Command



9
10
11
12
# File 'lib/dutchman/ghost_writer/apple_script/command.rb', line 9

def initialize(container,applescript)
  @container = container
  @applescript = applescript
end

Instance Attribute Details

#applescriptObject (readonly)

Returns the value of attribute applescript.



16
17
18
# File 'lib/dutchman/ghost_writer/apple_script/command.rb', line 16

def applescript
  @applescript
end

#containerObject (readonly)

Returns the value of attribute container.



14
15
16
# File 'lib/dutchman/ghost_writer/apple_script/command.rb', line 14

def container
  @container
end

Instance Method Details

#command_lineObject



26
27
28
# File 'lib/dutchman/ghost_writer/apple_script/command.rb', line 26

def command_line
  ERB.new(command_line_template).result(binding)
end

#command_line_templateObject



30
31
32
# File 'lib/dutchman/ghost_writer/apple_script/command.rb', line 30

def command_line_template
  template_with_name "command_line"
end

#executeObject



22
23
24
# File 'lib/dutchman/ghost_writer/apple_script/command.rb', line 22

def execute
  container.execute(self)
end

#template_with_name(name) ⇒ Object



34
35
36
# File 'lib/dutchman/ghost_writer/apple_script/command.rb', line 34

def template_with_name(name)
  File.read(File.join(File.dirname(__FILE__),"#{name}.erb"))
end

#to_sObject



18
19
20
# File 'lib/dutchman/ghost_writer/apple_script/command.rb', line 18

def to_s
  command_line
end