Class: Intent::Core::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/intent/core/directory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, projects) ⇒ Directory

Returns a new instance of Directory.



6
7
8
9
10
# File 'lib/intent/core/directory.rb', line 6

def initialize(path, projects)
  @path = path
  @ledger = projects
  @record = projects.all.find { |d| d.tags[:is] == 'directory' && d.text == @path }
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/intent/core/directory.rb', line 4

def path
  @path
end

Instance Method Details

#assign!(project) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/intent/core/directory.rb', line 20

def assign!(project)
  if record.nil?
    @record = Record.new("#{Date.today} #{@path} is:directory type:#{type} sku:#{sku}")
    ledger.append(record)
  else
    record.projects << project
  end

  ledger.save!
end

#is_linked?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/intent/core/directory.rb', line 16

def is_linked?
  !record.nil? && record.projects.any?
end

#projectObject



12
13
14
# File 'lib/intent/core/directory.rb', line 12

def project
  record.projects.first
end