<commit_before>require "genial/version"
require "httparty"

module Genial
  class Currency
    include HTTParty
    base_uri "http://api.xgeek.com.br/taxa-cambio"

    def self.find(code)
      parse_response(get("/currency?code=#{code}"))
    end

    def self.dollar
      parse_response(get("/currency?code=USD"))
    end

    def self.euro
      parse_response(get("/currency?code=EUR"))
    end

    def self.pound
      parse_response(get("/currency?code=GBP"))
    end

    private

    def self.parse_response(response)
      response.parsed_response["buying_rate"].to_f.round(2)
    end
  end
end<commit_msg>add converse method<commit_after>require "genial/version"
require "httparty"

module Genial
  class Currency
    include HTTParty
    base_uri "http://api.xgeek.com.br/taxa-cambio"

    def self.find(code)
      parse_response(get("/currency?code=#{code}"))
    end

    def self.dollar
      parse_response(get("/currency?code=USD"))
    end

    def self.euro
      parse_response(get("/currency?code=EUR"))
    end

    def self.pound
      parse_response(get("/currency?code=GBP"))
    end

    def self.convert(from, to ,value)
      parse_convert_response(get("/convert?from=#{from}&to=#{to}&value=#{value}"))
    end

    private

    def self.parse_response(response)
      response.parsed_response["buying_rate"].to_f.round(2)
    end

    def self.parse_convert_response(response)
        response.parsed_response["result"].to_f.round(2)
    end

  end
end
{'fraction_non_alphanumeric': 0.12744436952124072, 'fraction_numerical': 0.0020229265003371545, 'mean_word_length': 3.2890173410404624, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1400808', 'n_tokens_mistral': 513, 'n_tokens_neox': 493, 'n_words': 81}