Class: Dressmaker::Configuration::DirectoryRule::Pattern

Inherits:
Dressmaker::Configuration::DirectoryRule show all
Defined in:
lib/dressmaker/configuration/directory_rule.rb

Instance Attribute Summary collapse

Attributes inherited from Dressmaker::Configuration::DirectoryRule

#description, #name

Attributes inherited from Rule

#description, #informed

Instance Method Summary collapse

Methods inherited from Dressmaker::Configuration::DirectoryRule

#execute!

Methods inherited from Rule

#inform, #informed?

Constructor Details

#initialize(pattern, &action) ⇒ Pattern

Returns a new instance of Pattern.



20
21
22
23
# File 'lib/dressmaker/configuration/directory_rule.rb', line 20

def initialize(pattern, &action)
  @pattern = pattern
  @action = action
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



18
19
20
# File 'lib/dressmaker/configuration/directory_rule.rb', line 18

def action
  @action
end

#patternObject (readonly)

Returns the value of attribute pattern.



18
19
20
# File 'lib/dressmaker/configuration/directory_rule.rb', line 18

def pattern
  @pattern
end

Instance Method Details

#matches?(base, target) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/dressmaker/configuration/directory_rule.rb', line 25

def matches?(base, target)
  File.directory?(File.join(base, target)) && File.fnmatch(pattern, target)
end