Raise an error if paths isn't an array or hash

This commit is contained in:
Joshua Peek
2011-05-27 12:11:48 -05:00
parent 0b07d14a98
commit 3d7c9ab1ed

View File

@@ -20,13 +20,16 @@ module Linguist
# #
# Returns a Repository # Returns a Repository
def initialize(paths) def initialize(paths)
if paths.is_a?(Array) case paths
when Array
@paths = paths.inject({}) do |h, blob| @paths = paths.inject({}) do |h, blob|
h[blob.name] = blob h[blob.name] = blob
h h
end end
else when Hash
@paths = paths @paths = paths
else
raise ArgumentError, "#{paths.class} is not an Array or Hash"
end end
@computed_stats = false @computed_stats = false