Class: BLZ::Bank
- Inherits:
-
Object
- Object
- BLZ::Bank
- Defined in:
- lib/blz/bank.rb
Instance Attribute Summary collapse
-
#bic ⇒ Object
readonly
Returns the value of attribute bic.
-
#blz ⇒ Object
readonly
Returns the value of attribute blz.
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#short_name ⇒ Object
readonly
Returns the value of attribute short_name.
-
#zip ⇒ Object
readonly
Returns the value of attribute zip.
Class Method Summary collapse
-
.all ⇒ Object
Returns an array of all banks.
-
.find_by_bic(bic, options = {}) ⇒ Object
Returns an array of all Banks specified by
bic
(Business Identifier Code). -
.find_by_blz(code, options = {}) ⇒ Object
Returns an array of all Banks specified by
code
. -
.find_by_city(substring) ⇒ Object
Returns an array of all Banks with a substring of
city
.
Instance Method Summary collapse
-
#initialize(blz, name, zip, city, short_name, bic) ⇒ Bank
constructor
Initializes a single Bank record.
-
#to_s ⇒ Object
Returns a nice representation of the bank.
Constructor Details
#initialize(blz, name, zip, city, short_name, bic) ⇒ Bank
Initializes a single Bank record.
77 78 79 80 81 82 83 84 |
# File 'lib/blz/bank.rb', line 77 def initialize(blz, name, zip, city, short_name, bic) @blz = blz @name = name @zip = zip @city = city @bic = bic @short_name = short_name end |
Instance Attribute Details
#bic ⇒ Object (readonly)
Returns the value of attribute bic.
74 75 76 |
# File 'lib/blz/bank.rb', line 74 def bic @bic end |
#blz ⇒ Object (readonly)
Returns the value of attribute blz.
74 75 76 |
# File 'lib/blz/bank.rb', line 74 def blz @blz end |
#city ⇒ Object (readonly)
Returns the value of attribute city.
74 75 76 |
# File 'lib/blz/bank.rb', line 74 def city @city end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
74 75 76 |
# File 'lib/blz/bank.rb', line 74 def name @name end |
#short_name ⇒ Object (readonly)
Returns the value of attribute short_name.
74 75 76 |
# File 'lib/blz/bank.rb', line 74 def short_name @short_name end |
#zip ⇒ Object (readonly)
Returns the value of attribute zip.
74 75 76 |
# File 'lib/blz/bank.rb', line 74 def zip @zip end |
Class Method Details
.all ⇒ Object
Returns an array of all banks.
45 46 47 |
# File 'lib/blz/bank.rb', line 45 def all @banks ||= read_banks end |
.find_by_bic(bic, options = {}) ⇒ Object
Returns an array of all Banks specified by bic
(Business Identifier Code). The following options apply:
exact:: Only return exact matches (false by default)
35 36 37 38 39 40 41 42 |
# File 'lib/blz/bank.rb', line 35 def find_by_bic(bic, = {}) return [] if blank?(bic) exact = .fetch(:exact, false) all.select do |bank| bank.bic == bic || (!exact && (bank.bic || '').start_with?(bic)) end end |
.find_by_blz(code, options = {}) ⇒ Object
Returns an array of all Banks specified by code
. The following options apply:
exact:: Only return exact matches (false by default)
13 14 15 16 17 18 19 20 |
# File 'lib/blz/bank.rb', line 13 def find_by_blz(code, = {}) return [] if blank?(code) exact = .fetch(:exact, false) all.select do |bank| bank.blz == code || (!exact && bank.blz.start_with?(code)) end end |
.find_by_city(substring) ⇒ Object
Returns an array of all Banks with a substring of city
.
23 24 25 26 27 28 29 |
# File 'lib/blz/bank.rb', line 23 def find_by_city(substring) return [] if blank?(substring) all.select do |bank| bank.city.index(substring) end end |
Instance Method Details
#to_s ⇒ Object
Returns a nice representation of the bank.
87 88 89 |
# File 'lib/blz/bank.rb', line 87 def to_s [blz, name, "#{zip} #{city}", bic].compact.reject(&:empty?).join(', ') end |