Parent

Deprecatable::CallSite

CallSite represents a location in the source code where a DeprecatedMethod was invoked. It contains the location of the call site, the number of times that it was invoked, and an extraction of the source code around the invocation site

Attributes

context_padding[R]

Public: Gets the number of lines before and after the line_nubmer to also capture when gettin the context.

This number is the number both before AND after ‘line_number’ to capture. If this number is 2, then the total number of lines captured should be 5. 2 before, the line in question, and 2 after.

Returns the number of lines

file[R]

Public: Get the fully expand path of the file of the CallSite

Returns the String filesystem path of the file.

invocation_count[R]

Public: The number of times this CallSite has been invoked.

Returns the Integer number of times this call site has been invoked.

line_number[R]

Public: Get the line number of the CallSite in the file. Line numbers start at 1.

Returns the line number of a line in the file.

Public Class Methods

gen_key( file, line_number ) click to toggle source

Generate the hash key for a call site with the given file and line number.

file - A String that is the filesystem path to a file. line_number - An Integer that is the line number in the given file.

Returns a String that is generally used as a unique key.

# File lib/deprecatable/call_site.rb, line 15
def self.gen_key( file, line_number )
  "#{file}:#{line_number}"
end
new( file, line_number, context_padding ) click to toggle source

Create a new instance of CallSite

file - A String pathname of the file where the CallSite

happend

line_number - The Integer line number in the file. context_padding - The Integer number of lines both before and after

the 'line_nubmer' to capture.
# File lib/deprecatable/call_site.rb, line 52
def initialize( file, line_number, context_padding )
  @file             = File.expand_path( file )
  @line_number      = line_number
  @context_padding  = context_padding
  @invocation_count = 0
end

Public Instance Methods

context() click to toggle source

Retrieve the lazily loaded CallSiteContext.

Returns an instances of CallSiteContext

# File lib/deprecatable/call_site.rb, line 80
def context
  @context ||= CallSiteContext.new( @file, @line_number, @context_padding )
end
formatted_context_lines() click to toggle source

Access the lines of the context in a nicely formatted way.

Returns an Array of Strings containing the formatted context.

# File lib/deprecatable/call_site.rb, line 87
def formatted_context_lines
  context.formatted_context_lines
end
increment_invocation_count( count = 1 ) click to toggle source

Increment the invocation count by the amount given

count - The amount to increment the invocation count by

This should rarely, if ever be set.
(default: 1)

Returns the Integer invocation count.

# File lib/deprecatable/call_site.rb, line 73
def increment_invocation_count( count = 1 )
  @invocation_count += count
end
key() click to toggle source

The unique identifier of this CallSite.

Returns the String key of this CallSite.

# File lib/deprecatable/call_site.rb, line 62
def key
  CallSite.gen_key( file, line_number )
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.