Class: Coinone::Account::Balance

Inherits:
Object
  • Object
show all
Defined in:
lib/coinone/account/balance.rb,
lib/coinone/account/balance/wallet.rb,
lib/coinone/account/balance/normal_wallet.rb

Defined Under Namespace

Classes: NormalWallet, Wallet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Balance

Returns a new instance of Balance.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/coinone/account/balance.rb', line 13

def initialize(options={})

  @result = options[:result] || nil
  @normal_wallets = []
  @btc = Wallet.new()
  @eth = Wallet.new()
  @etc = Wallet.new()

  keys = [:normalWallets, :btc, :eth, :eth]
  update_balance(options) if keys.any? { |key| options.has_key? key}


end

Instance Attribute Details

#btcObject (readonly)

Returns the value of attribute btc.



11
12
13
# File 'lib/coinone/account/balance.rb', line 11

def btc
  @btc
end

#etcObject (readonly)

Returns the value of attribute etc.



11
12
13
# File 'lib/coinone/account/balance.rb', line 11

def etc
  @etc
end

#ethObject (readonly)

Returns the value of attribute eth.



11
12
13
# File 'lib/coinone/account/balance.rb', line 11

def eth
  @eth
end

#normal_walletsObject (readonly)

Returns the value of attribute normal_wallets.



11
12
13
# File 'lib/coinone/account/balance.rb', line 11

def normal_wallets
  @normal_wallets
end

#resultObject (readonly)

Returns the value of attribute result.



10
11
12
# File 'lib/coinone/account/balance.rb', line 10

def result
  @result
end

Instance Method Details

#update_balance(params = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/coinone/account/balance.rb', line 27

def update_balance(params={})


  @result = params[:result] if params.has_key? :result
  if params.has_key? :normalWallets
    @normal_wallets.clear
    params[:normalWallets].each do |wallet|
      @normal_wallets.push(NormalWallet.new(wallet))
    end
  end

  @btc.update_wallet(params[:btc]) if params.has_key? :btc
  @eth.update_wallet(params[:eth]) if params.has_key? :eth
  @etc.update_wallet(params[:etc]) if params.has_key? :etc

end