Module: FinderColor

Extended by:
FinderColor
Included in:
FinderColor
Defined in:
lib/finder_color.rb,
lib/finder_color.rb

Constant Summary collapse

VERSION =
'0.5.0'
Labels =
[:none, :orange, :red, :yellow, :blue, :purple, :green, :gray ]
Finder =
app.by_id( 'com.apple.Finder')

Class Method Summary collapse

Class Method Details

.batch_set(batch) ⇒ Object

batch_set takes a hash where the keys are indices or color symbols (e.g. :green) and the values are arrays of file paths.

Example:

{ :blue =>  [ '/Users/matthew/Documents/fan_letters/Wolfe,Gene',
              '/Users/matthew/Documents/fan_letters/Duncan,Dave'],
  :red =>   [ '/Users/matthew/Documents/restraining_orders/Wolfe,Gene']   }


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

def self.batch_set(batch)
  batch.each do |k,files|
    files.each do |file|
      set_label_color mac_file_url(file), k
    end
  end
end

.get_color(file_path) ⇒ Object

Returns a symbol from FinderColor::Labels (e.g. :blue, :purple) to indicate the file color



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

def self.get_color(file_path)
  Labels[mac_file_url(file_path).label_index.get]
end

.get_index(file_path) ⇒ Object

Returns the Finder label index for the given file



16
17
18
# File 'lib/finder_color.rb', line 16

def self.get_index(file_path)
  mac_file_url(file_path).label_index.get
end

.set_color(file_path, color) ⇒ Object

Given a symbol in [:none, :orange, :red, :yellow, :blue, :purple, :green, :gray ], sets the Finder label color accordingly.



33
34
35
# File 'lib/finder_color.rb', line 33

def self.set_color(file_path, color)
  set_label_color(mac_file_url(file_path), color)
end

.set_index(file_path, index) ⇒ Object

Set the Finder label to the given index, which must an integer from 0 to 7. See FinderColor::Labels for a mapping of indices to colors



27
28
29
# File 'lib/finder_color.rb', line 27

def self.set_index(file_path, index)
  set_label_color(mac_file_url(file_path), index)
end