Class: Bitstamper::Models::Deposit

Inherits:
Base
  • Object
show all
Defined in:
lib/bitstamper/models/deposit.rb

Constant Summary collapse

MAPPING =
{
  "address"         =>   :string,
  "amount"          =>   :float,
  "confirmations"   =>   :integer,
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attributes

Constructor Details

#initialize(hash) ⇒ Deposit

Returns a new instance of Deposit.



12
13
14
15
16
17
18
# File 'lib/bitstamper/models/deposit.rb', line 12

def initialize(hash)
  hash.each do |key, value|
    type            =     ::Bitstamper::Models::Deposit::MAPPING.fetch(key, nil)
    value           =     value && type ? ::Bitstamper::Utilities::convert_value(value, type) : value
    self.send("#{key}=", value) if self.respond_to?(key)
  end
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



4
5
6
# File 'lib/bitstamper/models/deposit.rb', line 4

def address
  @address
end

#amountObject

Returns the value of attribute amount.



4
5
6
# File 'lib/bitstamper/models/deposit.rb', line 4

def amount
  @amount
end

#confirmationsObject

Returns the value of attribute confirmations.



4
5
6
# File 'lib/bitstamper/models/deposit.rb', line 4

def confirmations
  @confirmations
end

Class Method Details

.parse(data) ⇒ Object



20
21
22
# File 'lib/bitstamper/models/deposit.rb', line 20

def self.parse(data)
  data&.collect { |item| ::Bitstamper::Models::Deposit.new(item) }
end