Class: Account

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/account_service/account.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#balanceObject

Returns the value of attribute balance.



5
6
7
# File 'lib/account_service/account.rb', line 5

def balance
  @balance
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/account_service/account.rb', line 4

def id
  @id
end

#nameObject

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