Class: ZenginLite::Bank
- Inherits:
-
Object
- Object
- ZenginLite::Bank
- Defined in:
- lib/zengin_lite/bank.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#hira ⇒ Object
readonly
Returns the value of attribute hira.
-
#kana ⇒ Object
readonly
Returns the value of attribute kana.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#roma ⇒ Object
readonly
Returns the value of attribute roma.
Class Method Summary collapse
Instance Method Summary collapse
- #branch(branch_code) ⇒ Object
- #branches(limit: nil) ⇒ Object
-
#initialize(code:, name:, kana:, hira:, roma:) ⇒ Bank
constructor
A new instance of Bank.
- #inspect ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(code:, name:, kana:, hira:, roma:) ⇒ Bank
19 20 21 22 23 24 25 |
# File 'lib/zengin_lite/bank.rb', line 19 def initialize(code:, name:, kana:, hira:, roma:) @code = code @name = name @kana = kana @hira = hira @roma = roma end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
17 18 19 |
# File 'lib/zengin_lite/bank.rb', line 17 def code @code end |
#hira ⇒ Object (readonly)
Returns the value of attribute hira.
17 18 19 |
# File 'lib/zengin_lite/bank.rb', line 17 def hira @hira end |
#kana ⇒ Object (readonly)
Returns the value of attribute kana.
17 18 19 |
# File 'lib/zengin_lite/bank.rb', line 17 def kana @kana end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'lib/zengin_lite/bank.rb', line 17 def name @name end |
#roma ⇒ Object (readonly)
Returns the value of attribute roma.
17 18 19 |
# File 'lib/zengin_lite/bank.rb', line 17 def roma @roma end |
Class Method Details
.[](code) ⇒ Object
12 13 14 |
# File 'lib/zengin_lite/bank.rb', line 12 def [](code) ZenginLite.bank(code) end |
.all ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/zengin_lite/bank.rb', line 4 def all banks = {} ZenginLite.each_bank do |bank| banks[bank.code] = bank end banks end |
.from_row(row) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/zengin_lite/bank.rb', line 53 def self.from_row(row) return nil unless row new( code: row[0], name: row[1], kana: row[2], hira: row[3], roma: row[4] ) end |
Instance Method Details
#branch(branch_code) ⇒ Object
27 28 29 30 |
# File 'lib/zengin_lite/bank.rb', line 27 def branch(branch_code) row = Database.find_branch(bank_code: code, branch_code: branch_code) Branch.from_row(row) if row end |
#branches(limit: nil) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/zengin_lite/bank.rb', line 32 def branches(limit: nil) Database.find_branches(bank_code: code, limit: limit).each_with_object({}) do |row, hash| branch = Branch.from_row(row) hash[branch.code] = branch end end |
#inspect ⇒ Object
49 50 51 |
# File 'lib/zengin_lite/bank.rb', line 49 def inspect "#<#{self.class.name} code=#{code.inspect}, name=#{name.inspect}, kana=#{kana.inspect}>" end |
#to_h ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/zengin_lite/bank.rb', line 39 def to_h { code: code, name: name, kana: kana, hira: hira, roma: roma } end |