Class: Atlasq::Command::Language

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

def content
  if search_terms.empty?
    languages = Data.all_languages
    Format.languages(languages)
  else
    search_terms.map do |term|
      if (languages = Data.countries_by_languages(term))
        Format.languages(languages)
      elsif (currency_codes = PartialMatch.languages(term)).any?
        languages = Data.countries_by_languages(currency_codes)
        Format.languages(languages, partial_match: true)
      else
        Atlasq.failed!
        "Unknown language: #{term}"
      end
    end.join("\n\n")
  end
end