Class: TestParser::SnippetSource::LineNumber

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/test_parser/snippet_source/line_number.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common

#source_code

Constructor Details

#initialize(file, line_number) ⇒ LineNumber

Returns a new instance of LineNumber.



11
12
13
# File 'lib/test_parser/snippet_source/line_number.rb', line 11

def initialize(file, line_number)
  @file, @line_number = file, line_number
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/test_parser/snippet_source/line_number.rb', line 7

def file
  @file
end

#line_numberObject (readonly)

Returns the value of attribute line_number.



7
8
9
# File 'lib/test_parser/snippet_source/line_number.rb', line 7

def line_number
  @line_number
end

Instance Method Details

#snippetObject



15
16
17
18
19
# File 'lib/test_parser/snippet_source/line_number.rb', line 15

def snippet
  source_code.extract_code_from_line(line_number)
rescue NoCodeInLineError
  raise "File: #{@file}:#{@line_number}"
end