Class: Atlasq::Command::Any

Inherits:
Base
  • Object
show all
Defined in:
lib/atlasq/command/any.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
25
# File 'lib/atlasq/command/any.rb', line 9

def content
  search_terms.map do |term|
    if (country = Data.country(term))
      Format.country(country)
    elsif (country_codes = Data.countries_by_region(term))
      region_name = Util::String.titleize(term)
      Format.countries(country_codes, title: "Region: #{region_name}")
    elsif (currencies = Data.countries_by_currencies(term))
      Format.currencies(currencies)
    elsif (languages = Data.countries_by_languages(term))
      Format.languages(languages)
    else
      Atlasq.failed!
      "Unknown search term: #{term}"
    end
  end.join("\n\n")
end