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_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.
46 47 48 49 50 51 52 53 |
# File 'lib/blz/bank.rb', line 46 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.
43 44 45 |
# File 'lib/blz/bank.rb', line 43 def bic @bic end |
#blz ⇒ Object (readonly)
Returns the value of attribute blz.
43 44 45 |
# File 'lib/blz/bank.rb', line 43 def blz @blz end |
#city ⇒ Object (readonly)
Returns the value of attribute city.
43 44 45 |
# File 'lib/blz/bank.rb', line 43 def city @city end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
43 44 45 |
# File 'lib/blz/bank.rb', line 43 def name @name end |
#short_name ⇒ Object (readonly)
Returns the value of attribute short_name.
43 44 45 |
# File 'lib/blz/bank.rb', line 43 def short_name @short_name end |
#zip ⇒ Object (readonly)
Returns the value of attribute zip.
43 44 45 |
# File 'lib/blz/bank.rb', line 43 def zip @zip end |
Class Method Details
.all ⇒ Object
Returns an array of all banks.
27 28 29 |
# File 'lib/blz/bank.rb', line 27 def all @banks ||= read_banks 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)
12 13 14 15 16 17 |
# File 'lib/blz/bank.rb', line 12 def find_by_blz(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.
20 21 22 23 24 |
# File 'lib/blz/bank.rb', line 20 def find_by_city(substring) all.select do |bank| bank.city.index(substring) end end |
Instance Method Details
#to_s ⇒ Object
Returns a nice representation of the bank.
56 57 58 |
# File 'lib/blz/bank.rb', line 56 def to_s [blz, name, "#{zip} #{city}", bic].compact.reject(&:empty?).join(', ') end |