Class: Pumi::Bot::Wikipedia::CommunesInCambodiaArticle::Location

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/pumi/bot/wikipedia/communes_in_cambodia_article.rb

Direct Known Subclasses

District, Province

Instance Method Summary collapse

Instance Method Details

#communes_summaryObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pumi/bot/wikipedia/communes_in_cambodia_article.rb', line 9

def communes_summary
  summary = communes_by_type.map do |administrative_unit, communes|
    next if Array(communes).empty?

    text = "#{communes.size} #{administrative_unit.name_en}"
    text << "s" if communes.size > 1
    text << " (#{administrative_unit.name_km} #{administrative_unit.name_latin})"
  end

  summary << "#{format_number(villages_count)} Villages (ភូមិ Phum)"

  if summary.size <= 2
    summary.join(" and ")
  else
    [summary[0..-2].join(", "), summary[-1]].join(" and ")
  end
end