Sha256: 1100e1a43b52da8700b512c4d606c9818cc16f658724392b5774185787cd6957

Contents?: true

Size: 522 Bytes

Versions: 2

Compression:

Stored size: 522 Bytes

Contents

# frozen_string_literal: true

require 'yaml'

module Bs2Api
  module Util
    class BankService
      class << self
        def find_by_code code
          code = code.to_s.strip.to_i
          bank = bank_list.find {|b| b["code"].to_i == code }
          raise Bs2Api::Errors::MissingBank, "Bank with code '#{code}' not registered into configuration file" if bank.blank?

          bank
        end

        def bank_list
          YAML.load_file(File.join(__dir__, 'banks.yml'))
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bs2_api-1.1.7 lib/bs2_api/util/bank_service.rb
bs2_api-1.1.6 lib/bs2_api/util/bank_service.rb