Class: Atlasq::Command::Region

Inherits:
Base
  • Object
show all
Defined in:
lib/atlasq/command/region.rb

Instance Attribute Summary

Attributes inherited from Base

#search_terms

Instance Method Summary collapse

Methods inherited from Base

#initialize, run, to_pager?

Constructor Details

This class inherits a constructor from Atlasq::Command::Base

Instance Method Details

#contentString

Returns:

  • (String)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/atlasq/command/region.rb', line 9

def content
  if search_terms.empty?
    subregions = Data.all_subregions
    Format.subregions(subregions)
  else
    search_terms.map do |term|
      if (country_codes = Data.countries_by_region(term))
        region_name = Util::String.titleize(term)
        Format.countries(country_codes, title: "Region: #{region_name}")
      else
        Atlasq.failed!
        "Unknown region: #{term}"
      end
    end.join("\n\n")
  end
end