Sha256: 817c3336d01e5b748732d4b74cb3a387a2faa37818bfcb43d39990a31be04c52

Contents?: true

Size: 617 Bytes

Versions: 3

Compression:

Stored size: 617 Bytes

Contents

# frozen_string_literal: true

require "credit_card_info/proxy"
require "credit_card_info/cache"
require "credit_card_info/config"
require "credit_card_info/response"
require "credit_card_info/version"

module CreditCardInfo
  class Error < StandardError; end

  def self.config
    @config ||= Config.config
  end

  def self.fetch(value)
    code = extract_bin(value)
    Cache.fetch(code) { Proxy.fetch(code) }
  end

  def self.logger
    @logger ||= config.logger
  end

  # @return [String] first 5 digits of credit card number i.e. BIN
  def self.extract_bin(value)
    value.to_s.delete("\s")[0..5]
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
credit_card_info-0.2.0 lib/credit_card_info.rb
credit_card_info-0.1.1 lib/credit_card_info.rb
credit_card_info-0.1.0 lib/credit_card_info.rb