Permalink
Browse files

Refactor, comments.

  • Loading branch information...
1 parent ebdaae0 commit 6f3e40dd3ae453dfb3480c3867bd7d1b7a5f6e2b @gilesbowkett committed Sep 30, 2008
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/towelie.rb
View
8 lib/towelie.rb
@@ -65,20 +65,22 @@ def unique(dir)
def homonyms(dir)
parse dir
homonyms = []
+ # this picks up duplicates as well as homonyms, since a duplicate is technically also a homonym,
+ # and I should probably run .uniq on it also.
method_definitions.stepwise do |method_definition_1, method_definition_2|
homonyms << method_definition_1 if method_definition_1.name == method_definition_2.name
end
homonyms
end
def diff(threshold)
- diff_nodes = {}
+ diff_nodes = []
method_definitions.stepwise do |method_definition_1, method_definition_2|
if threshold >= (method_definition_1.body - method_definition_2.body).size
- diff_nodes[method_definition_1.name] = method_definition_1
+ diff_nodes << method_definition_1
# note this hash approach fails to record multiple one-node-diff methods with the same name
end
end
- diff_nodes.values
+ diff_nodes
end
# view

0 comments on commit 6f3e40d

Please sign in to comment.