Class: Cleaner::Actions::Label

Inherits:
Cleaner::Action show all
Defined in:
lib/cleaner/actions/label.rb

Constant Summary collapse

COLORS =
{
  :white  => 0,
  :orange => 1,
  :red    => 2,
  :yellow => 3,
  :blue   => 4,
  :purple => 5,
  :green  => 6,
  :gray   => 7,
}

Instance Attribute Summary

Attributes inherited from Cleaner::Action

#files, #options

Instance Method Summary collapse

Methods inherited from Cleaner::Action

#initialize

Constructor Details

This class inherits a constructor from Cleaner::Action

Instance Method Details

#executeObject



14
15
16
17
18
19
20
# File 'lib/cleaner/actions/label.rb', line 14

def execute
  code = COLORS[options[:color]]
  files.each do |path|
    script = %Q{tell application \\"Finder\\" to set label index of file (POSIX file \\"#{path}\\") to #{code}}
    `osascript -e "#{script}"`
  end
end