lib/media_wiki/gateway/users.rb in mediawiki-gateway-1.0.0 vs lib/media_wiki/gateway/users.rb in mediawiki-gateway-1.1.0

- old
+ new

@@ -35,12 +35,12 @@ )) end # Get user contributions # - # user: The user name - # count: Maximum number of contributions to retreive, or nil for all + # [user] The user name + # [count] Maximum number of contributions to retrieve, or nil for all # [options] Optional hash of options, eg. { 'ucnamespace' => 4 }. See http://www.mediawiki.org/wiki/API:Usercontribs # # Returns array of hashes containing the "item" attributes defined here: http://www.mediawiki.org/wiki/API:Usercontribs def contributions(user, count = nil, options = {}) result = [] @@ -49,9 +49,10 @@ 'ucuser' => user, 'uclimit' => @options[:limit] )) { |element| result << hash = {} element.attributes.each { |key, value| hash[key] = value } + break if count && result.size >= count } count ? result.take(count) : result end