Class: Chid::Commands::Currency::Current

Inherits:
Chid::Command show all
Defined in:
lib/chid/commands/currency/now.rb

Constant Summary

Constants inherited from Chid::Command

Chid::Command::COMMANDS

Instance Attribute Summary

Attributes inherited from Chid::Command

#options

Instance Method Summary collapse

Methods inherited from Chid::Command

command, help, #initialize, map_options_with_values, run

Constructor Details

This class inherits a constructor from Chid::Command

Instance Method Details

#fromObject



40
41
42
# File 'lib/chid/commands/currency/now.rb', line 40

def from
  options['-from']&.compact&.join || 'USD'
end

#runObject



31
32
33
34
# File 'lib/chid/commands/currency/now.rb', line 31

def run
  currency = CurrencyApi.convert(to: to, from: from)
  puts "1 #{from} is #{currency} #{to}"
end

#toObject



36
37
38
# File 'lib/chid/commands/currency/now.rb', line 36

def to
  options['-to']&.compact&.join || 'BRL'
end