class Chid::Commands::Currency::Convert

Public Instance Methods

amount() click to toggle source
# File lib/chid/commands/currency/convert.rb, line 35
def amount
  options['-amount']&.compact.first.to_f|| 0.0
end
from() click to toggle source
# File lib/chid/commands/currency/convert.rb, line 43
def from
  options['-from']&.compact&.join || 'USD'
end
run() click to toggle source
# File lib/chid/commands/currency/convert.rb, line 30
def run
  currency = CurrencyApi.convert(amount: amount, to: to, from: from)
  puts "Converted amount: #{amount} #{from} is #{currency} #{to}"
end
to() click to toggle source
# File lib/chid/commands/currency/convert.rb, line 39
def to
  options['-to']&.compact&.join || 'BRL'
end