Class: Yamlint::Parser::Comment

Inherits:
Object
  • Object
show all
Defined in:
lib/yamlint/parser/comment_extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#columnObject (readonly)

Returns the value of attribute column.



6
7
8
# File 'lib/yamlint/parser/comment_extractor.rb', line 6

def column
  @column
end

#inlineObject (readonly)

Returns the value of attribute inline.



6
7
8
# File 'lib/yamlint/parser/comment_extractor.rb', line 6

def inline
  @inline
end

#line_numberObject (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

#textObject (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

Returns:

  • (Boolean)


19
20
21
# File 'lib/yamlint/parser/comment_extractor.rb', line 19

def disable_directive?
  @text.match?(/yamllint\s+disable(-line)?/)
end

#disabled_rulesObject



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

Returns:

  • (Boolean)


23
24
25
# File 'lib/yamlint/parser/comment_extractor.rb', line 23

def enable_directive?
  @text.match?(/yamllint\s+enable/)
end

#inline?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/yamlint/parser/comment_extractor.rb', line 15

def inline?
  @inline
end