Class: Dressmaker::Configuration::DirectoryRule
- Inherits:
-
Object
- Object
- Dressmaker::Configuration::DirectoryRule
- Defined in:
- lib/dressmaker/configuration/directory_rule.rb
Defined Under Namespace
Classes: DirectoryDelegator
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#description ⇒ Object
Returns the value of attribute description.
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #execute!(target) ⇒ Object
-
#initialize(directory, &action) ⇒ DirectoryRule
constructor
A new instance of DirectoryRule.
- #matches?(target) ⇒ Boolean
Constructor Details
#initialize(directory, &action) ⇒ DirectoryRule
Returns a new instance of DirectoryRule.
11 12 13 14 |
# File 'lib/dressmaker/configuration/directory_rule.rb', line 11 def initialize(directory, &action) @directory = directory @action = action end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
8 9 10 |
# File 'lib/dressmaker/configuration/directory_rule.rb', line 8 def action @action end |
#description ⇒ Object
Returns the value of attribute description.
9 10 11 |
# File 'lib/dressmaker/configuration/directory_rule.rb', line 9 def description @description end |
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
8 9 10 |
# File 'lib/dressmaker/configuration/directory_rule.rb', line 8 def directory @directory end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/dressmaker/configuration/directory_rule.rb', line 9 def name @name end |
Instance Method Details
#execute!(target) ⇒ Object
21 22 23 24 25 |
# File 'lib/dressmaker/configuration/directory_rule.rb', line 21 def execute!(target) Dressmaker.inform(self, description) if description dir = DirectoryDelegator.new(File.open(File.join(target, directory))) action.call(dir) end |
#matches?(target) ⇒ Boolean
16 17 18 19 |
# File 'lib/dressmaker/configuration/directory_rule.rb', line 16 def matches?(target) self.name = "Directory (#{File.join(target, directory)})" File.directory?(File.join(target, directory)) end |