Class: Nanoc::RuleDSL::Rule Private

Inherits:
Object
  • Object
show all
Includes:
Core::ContractsSupport
Defined in:
lib/nanoc/rule_dsl/rule.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Direct Known Subclasses

CompilationRule, RoutingRule

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern, rep_name, block) ⇒ Rule

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Rule.



14
15
16
17
18
# File 'lib/nanoc/rule_dsl/rule.rb', line 14

def initialize(pattern, rep_name, block)
  @pattern = pattern
  @rep_name = rep_name.to_sym
  @block = block
end

Instance Attribute Details

#patternObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



11
12
13
# File 'lib/nanoc/rule_dsl/rule.rb', line 11

def pattern
  @pattern
end

#rep_nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
# File 'lib/nanoc/rule_dsl/rule.rb', line 8

def rep_name
  @rep_name
end

Instance Method Details

#applicable_to?(item) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


21
22
23
# File 'lib/nanoc/rule_dsl/rule.rb', line 21

def applicable_to?(item)
  @pattern.match?(item.identifier)
end

#matches(identifier) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



27
28
29
# File 'lib/nanoc/rule_dsl/rule.rb', line 27

def matches(identifier)
  @pattern.captures(identifier)
end