Permalink
Browse files

Add comments to protected methods of `Pry::Code`

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
  • Loading branch information...
kyrylo committed Jan 3, 2013
1 parent 59e0a89 commit 84f6604fe124ffb4ae3c8269319ca91df56e9c63
Showing with 13 additions and 0 deletions.
  1. +13 −0 lib/pry/code.rb
View
@@ -393,6 +393,10 @@ def add_indentation(line_tuple)
line_tuple[0] = "#{ ' ' * @indentation_num }#{ line_tuple[0] }"
end
+ # If +end_line+ is `nil`, then assign to it +start_line+.
+ # @param [Integer, Range] start_line
+ # @param [Integer] end_line
+ # @return [Array<Integer>]
def reform_start_and_end_lines(start_line, end_line)
if start_line.is_a?(Range)
get_start_and_end_from_range(start_line)
@@ -402,20 +406,29 @@ def reform_start_and_end_lines(start_line, end_line)
end
end
+ # @param [Integer] start_line
+ # @param [Integer] end_line
+ # @return [Array<Integer>]
def start_and_end_indices(start_line, end_line)
return find_start_index(start_line), find_end_index(end_line)
end
+ # @param [Integer] start_line
+ # @return [Integer]
def find_start_index(start_line)
return start_line if start_line < 0
@lines.index { |l| l.last >= start_line } || @lines.length
end
+ # @param [Integer] end_line
+ # @return [Integer]
def find_end_index(end_line)
return end_line if end_line < 0
(@lines.index { |l| l.last > end_line } || 0) - 1
end
+ # @param [Range] range
+ # @return [Array<Integer>]
def get_start_and_end_from_range(range)
end_line = range.last
end_line -= 1 if range.exclude_end?

0 comments on commit 84f6604

Please sign in to comment.