Class: BSB::DatabaseGenerator
- Inherits:
-
Object
- Object
- BSB::DatabaseGenerator
- Defined in:
- lib/bsb/database_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash) ⇒ DatabaseGenerator
constructor
A new instance of DatabaseGenerator.
- #json ⇒ Object
Constructor Details
#initialize(hash) ⇒ DatabaseGenerator
Returns a new instance of DatabaseGenerator.
5 6 7 |
# File 'lib/bsb/database_generator.rb', line 5 def initialize(hash) @hash = hash end |
Class Method Details
.load_file(filename) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bsb/database_generator.rb', line 13 def self.load_file(filename) require 'net/ftp' ftp = Net::FTP.new('apca.com.au') ftp.login ftp.passive = true content = ftp.gettextfile(filename, nil) hash = {} content.each_line do |line| next if line[3] != "-" bsb = line[0,3] + line[4,3] hash[bsb] = [line[7,3], line[10,35].strip, line[45,35].strip, line[80,20].strip, line[100,3].strip, line[103,4], line[107,3]] end new(hash) end |
Instance Method Details
#json ⇒ Object
9 10 11 |
# File 'lib/bsb/database_generator.rb', line 9 def json JSON.dump(@hash) end |