Class: ProductionBreakpoints::MethodOverride

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-production-breakpoints/method_override.rb

Overview

Extract valueable parts of the method

Instance Method Summary collapse

Constructor Details

#initialize(parser, start_line, end_line) ⇒ MethodOverride

Returns a new instance of MethodOverride.



6
7
8
9
10
11
12
# File 'lib/ruby-production-breakpoints/method_override.rb', line 6

def initialize(parser, start_line, end_line)
  @parser = parser
  @source_lines = parser.source_lines
  @node = parser.find_definition_node(start_line, end_line)
  @start_line = start_line
  @end_line = end_line
end

Instance Method Details

#handler_srcObject



20
21
22
# File 'lib/ruby-production-breakpoints/method_override.rb', line 20

def handler_src
  @source_lines[@start_line - 1..@end_line - 1]
end

#resume_srcObject



24
25
26
27
28
# File 'lib/ruby-production-breakpoints/method_override.rb', line 24

def resume_src
  return if @node.last_lineno - @end_line <= 1 # if smaller or equal to one that means we are at the end of the method

   @source_lines[@end_line..(@node.last_lineno - 2)]
end

#unmodified_srcObject



14
15
16
17
18
# File 'lib/ruby-production-breakpoints/method_override.rb', line 14

def unmodified_src
  return if @start_line - @node.first_lineno <= 1 # if smaller or equal to one that means we are at the beginning of the method

   @source_lines[(@node.first_lineno)..(@start_line - 2)]
end