Class: Atlasq::Command::Money

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

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