Class: Account
- Inherits:
-
Object
- Object
- Account
- Defined in:
- lib/account.rb
Instance Attribute Summary collapse
-
#balance ⇒ Object
Returns the value of attribute balance.
-
#card_blocked ⇒ Object
Returns the value of attribute card_blocked.
-
#card_number ⇒ Object
Returns the value of attribute card_number.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pin ⇒ Object
Returns the value of attribute pin.
-
#transactions ⇒ Object
Returns the value of attribute transactions.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, card_number, pin, balance, card_blocked) ⇒ Account
constructor
A new instance of Account.
Constructor Details
#initialize(name, card_number, pin, balance, card_blocked) ⇒ Account
Returns a new instance of Account.
6 7 8 9 10 11 12 |
# File 'lib/account.rb', line 6 def initialize(name, card_number, pin, balance, card_blocked) @name = name @card_number = card_number @pin = pin @balance = balance @card_blocked = card_blocked end |
Instance Attribute Details
#balance ⇒ Object
Returns the value of attribute balance.
4 5 6 |
# File 'lib/account.rb', line 4 def balance @balance end |
#card_blocked ⇒ Object
Returns the value of attribute card_blocked.
4 5 6 |
# File 'lib/account.rb', line 4 def card_blocked @card_blocked end |
#card_number ⇒ Object
Returns the value of attribute card_number.
4 5 6 |
# File 'lib/account.rb', line 4 def card_number @card_number end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/account.rb', line 4 def name @name end |
#pin ⇒ Object
Returns the value of attribute pin.
4 5 6 |
# File 'lib/account.rb', line 4 def pin @pin end |
#transactions ⇒ Object
Returns the value of attribute transactions.
4 5 6 |
# File 'lib/account.rb', line 4 def transactions @transactions end |
Class Method Details
.find_by_card_number(card_number) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/account.rb', line 14 def self.find_by_card_number(card_number) CSV.table(ACCOUNT_PATH).each do |entry| if entry[:card_number] == card_number return new(entry[:name], entry[:card_number], entry[:pin], entry[:balance], entry[:card_blocked]) end end nil end |