Class: FinderTags

Inherits:
Object
  • Object
show all
Defined in:
lib/finder_tags.rb,
lib/finder_tags/version.rb,
lib/finder_tags/titlecase.rb

Defined Under Namespace

Modules: Titlecase Classes: Tag

Constant Summary collapse

FINDERINFO_KEY =
"com.apple.FinderInfo"
USERTAGS_KEY =
"com.apple.metadata:_kMDItemUserTags"
TAG_BYTE_OFFSET =
9
LEGACY_COLORS =

i could do something tricksy (color >> 1), but I don’t feel like it two arrays of colors is fine by me

%i[
  none none
  grey grey
  green green
  purple purple
  blue blue
  yellow yellow
  red red
  orange orange
].freeze
MODERN_COLORS =
%i[
  none
  grey
  green
  purple
  blue
  yellow
  red
  orange
].freeze
VERSION =
"0.1.1"

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ FinderTags

Returns a new instance of FinderTags.



38
39
40
# File 'lib/finder_tags.rb', line 38

def initialize(file)
  @file = file
end

Instance Method Details

#extended_tagsObject



58
59
60
# File 'lib/finder_tags.rb', line 58

def extended_tags
  @extended_tags ||= raw_user_tags.map(&method(:raw_to_tag))
end

#legacy_tagObject



48
49
50
51
52
53
54
55
56
# File 'lib/finder_tags.rb', line 48

def legacy_tag
  @legacy_tag ||=
    begin
      return Tag.new("None", :none) if tag_byte.nil?

      color = LEGACY_COLORS[tag_byte.to_i]
      Tag.new(color.to_s.titlecase, color)
    end
end

#tagsObject



42
43
44
45
46
# File 'lib/finder_tags.rb', line 42

def tags
  tags = extended_tags
  tags = [legacy_tag] if tags.none? && legacy_tag.color != :none
  tags
end