Module: FSPath::Mac

Included in:
FSPath
Defined in:
lib/fspath/mac.rb

Constant Summary collapse

FINDER_LABEL_COLORS =
[nil, :grey, :green, :purple, :blue, :yellow, :red, :orange].freeze
FINDER_LABEL_COLOR_ALIASES =
{:gray => :grey}.freeze

Instance Method Summary collapse

Instance Method Details

#finder_labelObject

Get finder label (one of nil, :orange, :red, :yellow, :blue, :purple, :green and :grey)



15
16
17
# File 'lib/fspath/mac.rb', line 15

def finder_label
  FINDER_LABEL_COLORS[finder_label_number]
end

#finder_label=(color) ⇒ Object

Set finder label (:grey is same as :gray, nil or false as :none)



20
21
22
23
24
# File 'lib/fspath/mac.rb', line 20

def finder_label=(color)
  index = FINDER_LABEL_COLORS.index(FINDER_LABEL_COLOR_ALIASES[color] || color)
  raise "Unknown label #{color.inspect}" unless index
  self.finder_label_number = index
end

#move_to_trashObject

Move to trash



7
8
9
# File 'lib/fspath/mac.rb', line 7

def move_to_trash
  # actual implementation in extension
end

#spotlight_commentObject

Get spotlight comment



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

def spotlight_comment
  with_argv_tell_finder_to 'get comment of (POSIX file (item 1 of argv) as alias)'
end

#spotlight_comment=(comment) ⇒ Object

Set spotlight comment



32
33
34
# File 'lib/fspath/mac.rb', line 32

def spotlight_comment=(comment)
  with_argv_tell_finder_to 'set comment of (POSIX file (item 1 of argv) as alias) to (item 2 of argv)', comment.to_s
end