Class: Scryer::MethodInfo

Inherits:
Struct
  • Object
show all
Defined in:
lib/scryer/method_extractor.rb

Overview

Extracts each def/def self.x method from a parsed file as a MethodInfo (name, file, start/end line, source text) by walking the Ripper sexp tree for :def and :defs nodes. Sexp nodes don't carry an explicit end line, so we find it by locating the matching top-level statement boundary: the next sibling's start line minus one, or the bodystmt's last statement's line if there's no next sibling, with a fallback that scans forward for the line containing a bare "end" if neither is available. In practice, we don't need exact end lines for duplicate detection — the token stream (not the source substring) is what actually gets compared, so we lex from the method's body sexp's own descendants (whose positions we DO have precisely) rather than fragile source-line slicing.

Instance Attribute Summary collapse

Instance Attribute Details

#end_lineObject

Returns the value of attribute end_line

Returns:

  • (Object)

    the current value of end_line



16
17
18
# File 'lib/scryer/method_extractor.rb', line 16

def end_line
  @end_line
end

#fileObject

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



16
17
18
# File 'lib/scryer/method_extractor.rb', line 16

def file
  @file
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



16
17
18
# File 'lib/scryer/method_extractor.rb', line 16

def name
  @name
end

#source_snippetObject

Returns the value of attribute source_snippet

Returns:

  • (Object)

    the current value of source_snippet



16
17
18
# File 'lib/scryer/method_extractor.rb', line 16

def source_snippet
  @source_snippet
end

#start_lineObject

Returns the value of attribute start_line

Returns:

  • (Object)

    the current value of start_line



16
17
18
# File 'lib/scryer/method_extractor.rb', line 16

def start_line
  @start_line
end

#token_streamObject

Returns the value of attribute token_stream

Returns:

  • (Object)

    the current value of token_stream



16
17
18
# File 'lib/scryer/method_extractor.rb', line 16

def token_stream
  @token_stream
end