Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: naman2202/concurrency
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: zurb/concurrency
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on May 11, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    psnider30 Paul Snider
    Copy the full SHA
    7696aef View commit details
  2. Merge pull request #1 from zurb/premium-server-url

    change url to premium server and v7 api.
    psnider30 authored May 11, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    716a8c3 View commit details
Showing with 10 additions and 10 deletions.
  1. +10 −10 lib/concurrency.rb
20 changes: 10 additions & 10 deletions lib/concurrency.rb
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@
module Concurrency
class << self
attr_accessor :configuration
end
end

def self.configuration
@configuration ||= Configuration.new
end
@@ -19,7 +19,7 @@ def self.reset
def self.configure
yield(configuration)
end

def self.convert(*args)
if args.length == 3
Concurrency.convert_full(*args)
@@ -29,7 +29,7 @@ def self.convert(*args)
Concurrency.convert_full(args[0], Concurrency.configuration.from_currency, Concurrency.configuration.to_currency)
end
end

def self.conversion_rate(from = Concurrency.configuration.from_currency, to = Concurrency.configuration.to_currency)
if from == to
return 1.0
@@ -38,9 +38,9 @@ def self.conversion_rate(from = Concurrency.configuration.from_currency, to = Co
return rate
end
end

private

def self.convert_full(initial, from, to)
if from == to
return initial
@@ -52,13 +52,13 @@ def self.convert_full(initial, from, to)
return initial*rate
end
end

def self.get_rate(from, to)
puts "From:#{from}>>TO:#{to}>>APIKEY:#{Concurrency.configuration.api_key}"
if Concurrency.configuration.api_key.nil?
if Concurrency.configuration.api_key.nil?
raise "API Key is missing. Kindly set API key CONCURRENCY_APIKEY."
end
url = "https://free.currencyconverterapi.com/api/v6/convert?q=#{from}_#{to}&compact=ultra&apiKey=#{Concurrency.configuration.api_key}"
url = "https://api.currconv.com/api/v7/convert?q=#{from}_#{to}&compact=ultra&apiKey=#{Concurrency.configuration.api_key}"
uri = URI(url)
response = Net::HTTP.get(uri)
if response == nil
@@ -68,5 +68,5 @@ def self.get_rate(from, to)
rate = (parsed_response["#{from}_#{to}"]).to_f
return rate
end
end
end
end