Class: Yamlint::Rules::Base
- Inherits:
-
Object
- Object
- Yamlint::Rules::Base
- Defined in:
- lib/yamlint/rules/base.rb
Direct Known Subclasses
Anchors, CommentRule, CommentsIndentation, DocumentEnd, DocumentStart, EmptyLines, KeyDuplicates, KeyOrdering, LineRule, NewLineAtEndOfFile, NewLines, TokenRule
Class Attribute Summary collapse
-
.default_options ⇒ Object
readonly
Returns the value of attribute default_options.
-
.description ⇒ Object
readonly
Returns the value of attribute description.
-
.id ⇒ Object
readonly
Returns the value of attribute id.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
Class Method Summary collapse
- .defaults(options) ⇒ Object
- .desc(description) ⇒ Object
- .inherited(subclass) ⇒ Object
- .rule_id(id) ⇒ Object
Instance Method Summary collapse
- #check(_context) ⇒ Object
- #fixable? ⇒ Boolean
-
#initialize(config = {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(config = {}) ⇒ Base
Returns a new instance of Base.
29 30 31 32 |
# File 'lib/yamlint/rules/base.rb', line 29 def initialize(config = {}) @config = (self.class. || {}).merge(config) @level = @config[:level] || :error end |
Class Attribute Details
.default_options ⇒ Object (readonly)
Returns the value of attribute default_options.
7 8 9 |
# File 'lib/yamlint/rules/base.rb', line 7 def @default_options end |
.description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/yamlint/rules/base.rb', line 7 def description @description end |
.id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/yamlint/rules/base.rb', line 7 def id @id end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
27 28 29 |
# File 'lib/yamlint/rules/base.rb', line 27 def config @config end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
27 28 29 |
# File 'lib/yamlint/rules/base.rb', line 27 def level @level end |
Class Method Details
.defaults(options) ⇒ Object
17 18 19 |
# File 'lib/yamlint/rules/base.rb', line 17 def defaults() @default_options = end |
.desc(description) ⇒ Object
13 14 15 |
# File 'lib/yamlint/rules/base.rb', line 13 def desc(description) @description = description end |
.inherited(subclass) ⇒ Object
21 22 23 24 |
# File 'lib/yamlint/rules/base.rb', line 21 def inherited(subclass) super subclass.instance_variable_set(:@default_options, {}) end |
.rule_id(id) ⇒ Object
9 10 11 |
# File 'lib/yamlint/rules/base.rb', line 9 def rule_id(id) @id = id end |
Instance Method Details
#check(_context) ⇒ Object
34 35 36 |
# File 'lib/yamlint/rules/base.rb', line 34 def check(_context) raise NotImplementedError, "#{self.class}#check must be implemented" end |
#fixable? ⇒ Boolean
38 39 40 |
# File 'lib/yamlint/rules/base.rb', line 38 def fixable? false end |