Class: Intent::Core::Directory
- Inherits:
-
Object
- Object
- Intent::Core::Directory
- Defined in:
- lib/intent/core/directory.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #assign!(project) ⇒ Object
-
#initialize(path, projects) ⇒ Directory
constructor
A new instance of Directory.
- #is_linked? ⇒ Boolean
- #project ⇒ Object
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.[:is] == 'directory' && d.text == @path } end |
Instance Attribute Details
#path ⇒ Object (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
16 17 18 |
# File 'lib/intent/core/directory.rb', line 16 def is_linked? !record.nil? && record.projects.any? end |
#project ⇒ Object
12 13 14 |
# File 'lib/intent/core/directory.rb', line 12 def project record.projects.first end |