Class: Revolut::Api::Response::Pocket

Inherits:
Object
  • Object
show all
Defined in:
lib/revolut/api/response/pocket.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Pocket

Returns a new instance of Pocket.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/revolut/api/response/pocket.rb', line 9

def initialize(hash = {})
  self.id               =   hash.fetch("id", nil)
  self.state            =   hash.fetch("state", nil)

  self.currency         =   hash.fetch("currency", nil)

  self.balance          =   hash.fetch("balance", nil)
  self.balance          =   ::Revolut::Api::Utilities.convert_from_integer_amount(self.currency, self.balance) if !self.currency.to_s.empty? && !self.balance.nil?

  self.blocked_amount   =   hash.fetch("blockedAmount", nil)
  self.blocked_amount   =   ::Revolut::Api::Utilities.convert_from_integer_amount(self.currency, self.blocked_amount) if !self.currency.to_s.empty? && !self.blocked_amount.nil?
end

Instance Attribute Details

#balanceObject

Returns the value of attribute balance.



7
8
9
# File 'lib/revolut/api/response/pocket.rb', line 7

def balance
  @balance
end

#blocked_amountObject

Returns the value of attribute blocked_amount.



7
8
9
# File 'lib/revolut/api/response/pocket.rb', line 7

def blocked_amount
  @blocked_amount
end

#currencyObject

Returns the value of attribute currency.



6
7
8
# File 'lib/revolut/api/response/pocket.rb', line 6

def currency
  @currency
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/revolut/api/response/pocket.rb', line 5

def id
  @id
end

#stateObject

Returns the value of attribute state.



5
6
7
# File 'lib/revolut/api/response/pocket.rb', line 5

def state
  @state
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/revolut/api/response/pocket.rb', line 22

def active?
  in_state?(:active)
end

#in_state?(state) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/revolut/api/response/pocket.rb', line 26

def in_state?(state)
  self.state.downcase.strip.to_sym.eql?(state)
end