Class: BLZ::Bank

Inherits:
Object
  • Object
show all
Defined in:
lib/blz/bank.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#bicObject (readonly)

Returns the value of attribute bic.



43
44
45
# File 'lib/blz/bank.rb', line 43

def bic
  @bic
end

#blzObject (readonly)

Returns the value of attribute blz.



43
44
45
# File 'lib/blz/bank.rb', line 43

def blz
  @blz
end

#cityObject (readonly)

Returns the value of attribute city.



43
44
45
# File 'lib/blz/bank.rb', line 43

def city
  @city
end

#nameObject (readonly)

Returns the value of attribute name.



43
44
45
# File 'lib/blz/bank.rb', line 43

def name
  @name
end

#short_nameObject (readonly)

Returns the value of attribute short_name.



43
44
45
# File 'lib/blz/bank.rb', line 43

def short_name
  @short_name
end

#zipObject (readonly)

Returns the value of attribute zip.



43
44
45
# File 'lib/blz/bank.rb', line 43

def zip
  @zip
end

Class Method Details

.allObject

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, options = {})
  exact = options.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_sObject

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