Class: MacosTags::TagParser

Inherits:
Object
  • Object
show all
Defined in:
lib/macos-tags.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ TagParser

Returns a new instance of TagParser.



117
118
119
120
# File 'lib/macos-tags.rb', line 117

def initialize(file)
  @xattr = Xattr.new(file)
  @plist = CFPropertyList::List.new
end

Instance Attribute Details

#plistObject (readonly)

Returns the value of attribute plist.



116
117
118
# File 'lib/macos-tags.rb', line 116

def plist
  @plist
end

#xattrObject (readonly)

Returns the value of attribute xattr.



116
117
118
# File 'lib/macos-tags.rb', line 116

def xattr
  @xattr
end

Instance Method Details

#tagsObject



122
123
124
125
126
127
# File 'lib/macos-tags.rb', line 122

def tags
  (parse_raw_tags&.value || []).map do |raw_tag|
    label, color_val = raw_tag.value.split("\n")
    Tag.new(label: label, color: Color.new(color_val.to_i))
  end
end