Skip to content

Commit c1c28a5

Browse files
committed
Make the if / else statements more Rubyish
1 parent b9e2e4b commit c1c28a5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/rugged/index.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,16 @@ class Index
104104
def diff(*args)
105105
options = args.last.is_a?(Hash) ? args.pop : {}
106106
other = args.shift
107-
if other.nil?
107+
108+
case other
109+
when nil
108110
diff_index_to_workdir options
111+
when ::Rugged::Commit
112+
diff_tree_to_index other.tree, options
113+
when ::Rugged::Tree
114+
diff_tree_to_index other, options
109115
else
110-
if other.is_a? ::Rugged::Commit
111-
diff_tree_to_index other.tree, options
112-
elsif other.is_a? ::Rugged::Tree
113-
diff_tree_to_index other, options
114-
else
115-
raise TypeError, "A Rugged::Commit or Rugged::Tree instance is required"
116-
end
116+
raise TypeError, "A Rugged::Commit or Rugged::Tree instance is required"
117117
end
118118
end
119119

0 commit comments

Comments
 (0)