Class: Wasko::Applescript

Inherits:
Object
  • Object
show all
Defined in:
lib/wasko/applescript.rb

Class Method Summary collapse

Class Method Details

.runObject

Runs a piece of Applescript,

Wasko::Applescript.run do
  "set ten_and_ten to 10 + 10"
end
=> "20"

Since Applescript has a nasy bit of littering its return values with ‘n`, already escaping those.



12
13
14
15
# File 'lib/wasko/applescript.rb', line 12

def self.run
  value = `/usr/bin/osascript -e "#{yield.gsub('"', '\"')}"`
  value.gsub("\n", '')
end