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
66 67 68 69 |
# File 'lib/yardstick/rule.rb', line 66 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
18 19 20 |
# File 'lib/yardstick/rule.rb', line 18 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
55 56 57 |
# File 'lib/yardstick/rule.rb', line 55 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
46 47 48 |
# File 'lib/yardstick/rule.rb', line 46 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
79 80 81 |
# File 'lib/yardstick/rule.rb', line 79 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
88 89 90 |
# File 'lib/yardstick/rule.rb', line 88 def validatable? true end |