Class: Yamlint::Models::LintContext
- Inherits:
-
Object
- Object
- Yamlint::Models::LintContext
- Defined in:
- lib/yamlint/models/lint_context.rb
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#problems ⇒ Object
Returns the value of attribute problems.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
- #add_comment(comment) ⇒ Object
- #add_problem(problem) ⇒ Object
- #add_token(token) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(filepath:, content:) ⇒ LintContext
constructor
A new instance of LintContext.
- #line_at(line_number) ⇒ Object
- #line_count ⇒ Object
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
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
6 7 8 |
# File 'lib/yamlint/models/lint_context.rb', line 6 def comments @comments end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
6 7 8 |
# File 'lib/yamlint/models/lint_context.rb', line 6 def content @content end |
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
6 7 8 |
# File 'lib/yamlint/models/lint_context.rb', line 6 def filepath @filepath end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
6 7 8 |
# File 'lib/yamlint/models/lint_context.rb', line 6 def lines @lines end |
#problems ⇒ Object
Returns the value of attribute problems.
7 8 9 |
# File 'lib/yamlint/models/lint_context.rb', line 7 def problems @problems end |
#tokens ⇒ Object (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
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_count ⇒ Object
30 31 32 |
# File 'lib/yamlint/models/lint_context.rb', line 30 def line_count @lines.length end |