Class: CoinSync::Balance

Inherits:
Object
  • Object
show all
Defined in:
lib/coinsync/balance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(currency, available: BigDecimal(0), locked: BigDecimal(0)) ⇒ Balance

Returns a new instance of Balance.



5
6
7
8
9
# File 'lib/coinsync/balance.rb', line 5

def initialize(currency, available: BigDecimal(0), locked: BigDecimal(0))
  @currency = currency
  @available = available
  @locked = locked
end

Instance Attribute Details

#availableObject (readonly)

Returns the value of attribute available.



3
4
5
# File 'lib/coinsync/balance.rb', line 3

def available
  @available
end

#currencyObject (readonly)

Returns the value of attribute currency.



3
4
5
# File 'lib/coinsync/balance.rb', line 3

def currency
  @currency
end

#lockedObject (readonly)

Returns the value of attribute locked.



3
4
5
# File 'lib/coinsync/balance.rb', line 3

def locked
  @locked
end

Instance Method Details

#+(balance) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/coinsync/balance.rb', line 11

def +(balance)
  return Balance.new(
    @currency,
    available: @available + balance.available,
    locked: @locked + balance.locked
  )
end