Class: Account
- Inherits:
-
Object
- Object
- Account
- Includes:
- Comparable
- Defined in:
- lib/account_service/account.rb
Instance Attribute Summary collapse
-
#balance ⇒ Object
Returns the value of attribute balance.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(name, balance = 0) ⇒ Account
constructor
A new instance of Account.
Constructor Details
#initialize(name, balance = 0) ⇒ Account
Returns a new instance of Account.
7 8 9 10 11 |
# File 'lib/account_service/account.rb', line 7 def initialize(name, balance = 0) @name = name @balance = balance @id = rand(10) end |
Instance Attribute Details
#balance ⇒ Object
Returns the value of attribute balance.
5 6 7 |
# File 'lib/account_service/account.rb', line 5 def balance @balance end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/account_service/account.rb', line 4 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/account_service/account.rb', line 4 def name @name end |
Instance Method Details
#<=>(other) ⇒ Object
13 14 15 |
# File 'lib/account_service/account.rb', line 13 def <=>(other) @balance <=> other.balance end |