Class: Yamlint::Parser::LineParser

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

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ LineParser

Returns a new instance of LineParser.



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

def initialize(content)
  @content = content
end

Instance Method Details

#each_line_with_numberObject



23
24
25
26
27
# File 'lib/yamlint/parser/line_parser.rb', line 23

def each_line_with_number(&)
  parse.each_with_index do |line, index|
    yield(line, index + 1)
  end
end

#line_at(line_number) ⇒ Object



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

def line_at(line_number)
  lines = parse
  lines[line_number - 1]
end

#line_countObject



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

def line_count
  parse.length
end

#parseObject



10
11
12
# File 'lib/yamlint/parser/line_parser.rb', line 10

def parse
  @content.lines
end