class GoldPrice::CLI
CLI
Controller
Attributes
measurement[RW]
metal[RW]
Public Instance Methods
call()
click to toggle source
# File lib/gold_price/cli.rb, line 6 def call puts "Welcome to Gold Price!" puts "__*__" metal_menu end
goodbye()
click to toggle source
# File lib/gold_price/cli.rb, line 67 def goodbye puts "See you tomorrow! Stay Golden." end
price()
click to toggle source
# File lib/gold_price/cli.rb, line 38 def price @silver_prices = GoldPrice::Price.silver_prices @gold_prices = GoldPrice::Price.gold_prices silver_price = @silver_prices[0] gold_price = @gold_prices[0] if @metal == 1 && @measurement == 1 puts "Today the price of gold per gram is $#{gold_price.gold_by_gram} USD." puts "__*__" elsif @metal == 1 && @measurement == 2 puts "Today the price of gold per ounce is $#{gold_price.gold_by_ounce} USD." puts "__*__" elsif @metal == 2 && @measurement == 1 puts "Today the price of silver per gram is $#{silver_price.silver_by_gram} USD." puts "__*__" elsif @metal == 2 && @measurement == 2 puts "Today the price of silver per ounce is $#{silver_price.silver_by_ounce} USD." puts "__*__" end puts "Would you like to see another price?" input = gets.strip.upcase if input == "Y" || input == "YES" metal_menu else goodbye end end