Class: BSB::BankListGenerator
- Inherits:
-
Object
- Object
- BSB::BankListGenerator
- Defined in:
- lib/bsb/bank_list_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash) ⇒ BankListGenerator
constructor
A new instance of BankListGenerator.
- #json ⇒ Object
Constructor Details
#initialize(hash) ⇒ BankListGenerator
Returns a new instance of BankListGenerator.
7 8 9 |
# File 'lib/bsb/bank_list_generator.rb', line 7 def initialize(hash) @hash = hash end |
Class Method Details
.load_file(url) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bsb/bank_list_generator.rb', line 15 def self.load_file(url) hash = {} content = RestClient.get(url) CSV.parse(content) do |row| row[2].split(", ").each do |prefix| prefix = prefix.chomp.rjust(2, "0") hash[prefix] = row[1] end end new(hash) end |
Instance Method Details
#json ⇒ Object
11 12 13 |
# File 'lib/bsb/bank_list_generator.rb', line 11 def json JSON.dump(@hash) end |