Method: WikiBot::Category#count

Defined in:
lib/wikibot/core/category.rb

#count(include_subcats = false) ⇒ Object

Returns a hash of how many pages live in a category



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/wikibot/core/category.rb', line 34

def count(include_subcats = false)
  @count ||= begin
    out = {}
    ci = category_info

    out[@name] = {
      :pages => ci.pages.to_i
    }

    if include_subcats and ci.subcats.to_i > 0
      out[@name][:subcats] = {}
      members.each do |m|
        out[@name][:subcats].merge! self.class.new(@wiki_bot, m["title"]).count(include_subcats)
      end
    end

    out
  end
end