Class: Yamlint::Parser::Comment
- Inherits:
-
Object
- Object
- Yamlint::Parser::Comment
- Defined in:
- lib/yamlint/parser/comment_extractor.rb
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#inline ⇒ Object
readonly
Returns the value of attribute inline.
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #disable_directive? ⇒ Boolean
- #disabled_rules ⇒ Object
- #enable_directive? ⇒ Boolean
-
#initialize(line_number:, column:, text:, inline: false) ⇒ Comment
constructor
A new instance of Comment.
- #inline? ⇒ Boolean
Constructor Details
#initialize(line_number:, column:, text:, inline: false) ⇒ Comment
Returns a new instance of Comment.
8 9 10 11 12 13 |
# File 'lib/yamlint/parser/comment_extractor.rb', line 8 def initialize(line_number:, column:, text:, inline: false) @line_number = line_number @column = column @text = text @inline = inline end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
6 7 8 |
# File 'lib/yamlint/parser/comment_extractor.rb', line 6 def column @column end |
#inline ⇒ Object (readonly)
Returns the value of attribute inline.
6 7 8 |
# File 'lib/yamlint/parser/comment_extractor.rb', line 6 def inline @inline end |
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
6 7 8 |
# File 'lib/yamlint/parser/comment_extractor.rb', line 6 def line_number @line_number end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
6 7 8 |
# File 'lib/yamlint/parser/comment_extractor.rb', line 6 def text @text end |
Instance Method Details
#disable_directive? ⇒ Boolean
19 20 21 |
# File 'lib/yamlint/parser/comment_extractor.rb', line 19 def disable_directive? @text.match?(/yamllint\s+disable(-line)?/) end |
#disabled_rules ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/yamlint/parser/comment_extractor.rb', line 27 def disabled_rules if (match = @text.match(/yamllint\s+disable(-line)?\s+(.+)/)) match[2].split(/[,\s]+/).map(&:strip).reject(&:empty?) else [] end end |
#enable_directive? ⇒ Boolean
23 24 25 |
# File 'lib/yamlint/parser/comment_extractor.rb', line 23 def enable_directive? @text.match?(/yamllint\s+enable/) end |
#inline? ⇒ Boolean
15 16 17 |
# File 'lib/yamlint/parser/comment_extractor.rb', line 15 def inline? @inline end |