Class: Yamlint::Models::LintContext

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filepath:, content:) ⇒ LintContext

Returns a new instance of LintContext.



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

def initialize(filepath:, content:)
  @filepath = filepath
  @content = content
  @lines = content.lines
  @tokens = []
  @comments = []
  @problems = []
end

Instance Attribute Details

#commentsObject (readonly)

Returns the value of attribute comments.



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

def comments
  @comments
end

#contentObject (readonly)

Returns the value of attribute content.



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

def content
  @content
end

#filepathObject (readonly)

Returns the value of attribute filepath.



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

def filepath
  @filepath
end

#linesObject (readonly)

Returns the value of attribute lines.



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

def lines
  @lines
end

#problemsObject

Returns the value of attribute problems.



7
8
9
# File 'lib/yamlint/models/lint_context.rb', line 7

def problems
  @problems
end

#tokensObject (readonly)

Returns the value of attribute tokens.



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

def tokens
  @tokens
end

Instance Method Details

#add_comment(comment) ⇒ Object



26
27
28
# File 'lib/yamlint/models/lint_context.rb', line 26

def add_comment(comment)
  @comments << comment
end

#add_problem(problem) ⇒ Object



18
19
20
# File 'lib/yamlint/models/lint_context.rb', line 18

def add_problem(problem)
  @problems << problem
end

#add_token(token) ⇒ Object



22
23
24
# File 'lib/yamlint/models/lint_context.rb', line 22

def add_token(token)
  @tokens << token
end

#empty?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/yamlint/models/lint_context.rb', line 38

def empty?
  @content.empty?
end

#line_at(line_number) ⇒ Object



34
35
36
# File 'lib/yamlint/models/lint_context.rb', line 34

def line_at(line_number)
  @lines[line_number - 1]
end

#line_countObject



30
31
32
# File 'lib/yamlint/models/lint_context.rb', line 30

def line_count
  @lines.length
end