Class: Yamlint::Models::Problem

Inherits:
Object
  • Object
show all
Defined in:
lib/yamlint/models/problem.rb

Constant Summary collapse

LEVELS =
%i[error warning info].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line:, column:, rule:, level:, message:, fixable: false) ⇒ Problem

Returns a new instance of Problem.



10
11
12
13
14
15
16
17
# File 'lib/yamlint/models/problem.rb', line 10

def initialize(line:, column:, rule:, level:, message:, fixable: false)
  @line = line
  @column = column
  @rule = rule
  @level = validate_level(level)
  @message = message
  @fixable = fixable
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



6
7
8
# File 'lib/yamlint/models/problem.rb', line 6

def column
  @column
end

#fixableObject (readonly)

Returns the value of attribute fixable.



6
7
8
# File 'lib/yamlint/models/problem.rb', line 6

def fixable
  @fixable
end

#levelObject (readonly)

Returns the value of attribute level.



6
7
8
# File 'lib/yamlint/models/problem.rb', line 6

def level
  @level
end

#lineObject (readonly)

Returns the value of attribute line.



6
7
8
# File 'lib/yamlint/models/problem.rb', line 6

def line
  @line
end

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'lib/yamlint/models/problem.rb', line 6

def message
  @message
end

#ruleObject (readonly)

Returns the value of attribute rule.



6
7
8
# File 'lib/yamlint/models/problem.rb', line 6

def rule
  @rule
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/yamlint/models/problem.rb', line 19

def error?
  @level == :error
end

#fixable?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/yamlint/models/problem.rb', line 27

def fixable?
  @fixable
end

#to_sObject



31
32
33
# File 'lib/yamlint/models/problem.rb', line 31

def to_s
  "#{line}:#{column} [#{level}] #{message} (#{rule})"
end

#warning?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/yamlint/models/problem.rb', line 23

def warning?
  @level == :warning
end