Class: FieldMatter::DarkMatter

Inherits:
Object
  • Object
show all
Defined in:
lib/fieldmatter/darkmatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo_path) ⇒ DarkMatter

Returns a new instance of DarkMatter.



13
14
15
# File 'lib/fieldmatter/darkmatter.rb', line 13

def initialize( repo_path )
  @repo_path = repo_path
end

Instance Attribute Details

#repoObject (readonly)

Returns the value of attribute repo.



11
12
13
# File 'lib/fieldmatter/darkmatter.rb', line 11

def repo
  @repo
end

#repo_pathObject (readonly)

Returns the value of attribute repo_path.



11
12
13
# File 'lib/fieldmatter/darkmatter.rb', line 11

def repo_path
  @repo_path
end

#what_mattersObject (readonly)

Returns the value of attribute what_matters.



11
12
13
# File 'lib/fieldmatter/darkmatter.rb', line 11

def what_matters
  @what_matters
end

Instance Method Details

#updateObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fieldmatter/darkmatter.rb', line 25

def update 
  self.what_matters.each do | key, value |
    if not FieldMatter::Note.find(filename: key).empty?
      canon = Base64.encode64(key).chomp
      id = Ohm.redis.smembers("FieldMatter::Note:filename:#{canon}").pop
      note = FieldMatter::Note[id]
      note.update(:tags => value['kMDItemOMUserTags'])
    else
      FieldMatter::Note.create(:filename => key, :tags => value['kMDItemOMUserTags'])
    end
  end
end