Class: Yardstick::Rule Abstract
- Inherits:
-
Object
- Object
- Yardstick::Rule
- Extended by:
- Forwardable
- Defined in:
- lib/yardstick/rule.rb
Overview
Base class of every rule
Direct Known Subclasses
Yardstick::Rules::ApiTag::Inclusion, Yardstick::Rules::ApiTag::Presence, Yardstick::Rules::ApiTag::PrivateMethod, Yardstick::Rules::ApiTag::ProtectedMethod, Yardstick::Rules::ExampleTag, Yardstick::Rules::ReturnTag, Yardstick::Rules::Summary::Delimiter, Yardstick::Rules::Summary::Length, Yardstick::Rules::Summary::Presence, Yardstick::Rules::Summary::SingleLine
Class Attribute Summary collapse
-
.description ⇒ String
private
Description of the rule.
Instance Attribute Summary collapse
-
#document ⇒ Document
readonly
private
Return document that current rule is using.
Class Method Summary collapse
-
.coerce(document, config) ⇒ Yardstick::Rule
private
Makes a new instance of rule using given config.
Instance Method Summary collapse
-
#enabled? ⇒ Boolean
private
Checks if rule is enabled in current context.
-
#initialize(document, config = RuleConfig.new) ⇒ Yardstick::Rule
constructor
private
Initializes a rule.
-
#validatable? ⇒ Boolean
private
Checks if the rule is validatable for given document.
Constructor Details
#initialize(document, config = RuleConfig.new) ⇒ Yardstick::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.
Initializes a rule
68 69 70 71 |
# File 'lib/yardstick/rule.rb', line 68 def initialize(document, config = RuleConfig.new) @document = document @config = config end |
Class Attribute Details
.description ⇒ String
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.
Description of the rule
This is shown when a rule is invalid
20 21 22 |
# File 'lib/yardstick/rule.rb', line 20 def description @description end |
Instance Attribute Details
#document ⇒ Document (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.
Return document that current rule is using
57 58 59 |
# File 'lib/yardstick/rule.rb', line 57 def document @document end |
Class Method Details
.coerce(document, config) ⇒ Yardstick::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.
Makes a new instance of rule using given config
48 49 50 |
# File 'lib/yardstick/rule.rb', line 48 def self.coerce(document, config) new(document, config.for_rule(self)) end |
Instance Method Details
#enabled? ⇒ 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.
Checks if rule is enabled in current context
81 82 83 |
# File 'lib/yardstick/rule.rb', line 81 def enabled? @config.enabled_for_path?(@document.path) end |
#validatable? ⇒ 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.
Checks if the rule is validatable for given document
90 91 92 |
# File 'lib/yardstick/rule.rb', line 90 def validatable? true end |