Class: Coinbase::HistoricalBalance
- Inherits:
-
Object
- Object
- Coinbase::HistoricalBalance
- Defined in:
- lib/coinbase/historical_balance.rb
Overview
A representation of an HistoricalBalance.
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#asset ⇒ Object
readonly
Returns the value of attribute asset.
-
#block_hash ⇒ Object
readonly
Returns the value of attribute block_hash.
-
#block_height ⇒ Object
readonly
Returns the value of attribute block_height.
Class Method Summary collapse
-
.from_model(historical_balance_model) ⇒ HistoricalBalance
Converts a Coinbase::Client::HistoricalBalance model to a Coinbase::HistoricalBalance.
Instance Method Summary collapse
-
#initialize(amount:, block_height:, block_hash:, asset:) ⇒ HistoricalBalance
constructor
Returns a new HistoricalBalance object.
-
#inspect ⇒ String
Same as to_s.
-
#to_s ⇒ String
Returns a string representation of the HistoricalBalance.
Constructor Details
#initialize(amount:, block_height:, block_hash:, asset:) ⇒ HistoricalBalance
Returns a new HistoricalBalance object. Do not use this method. Instead, use Balance.from_model or Balance.from_model_and_asset_id.
26 27 28 29 30 31 |
# File 'lib/coinbase/historical_balance.rb', line 26 def initialize(amount:, block_height:, block_hash:, asset:) @amount = amount @block_height = block_height @block_hash = block_hash @asset = asset end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
33 34 35 |
# File 'lib/coinbase/historical_balance.rb', line 33 def amount @amount end |
#asset ⇒ Object (readonly)
Returns the value of attribute asset.
33 34 35 |
# File 'lib/coinbase/historical_balance.rb', line 33 def asset @asset end |
#block_hash ⇒ Object (readonly)
Returns the value of attribute block_hash.
33 34 35 |
# File 'lib/coinbase/historical_balance.rb', line 33 def block_hash @block_hash end |
#block_height ⇒ Object (readonly)
Returns the value of attribute block_height.
33 34 35 |
# File 'lib/coinbase/historical_balance.rb', line 33 def block_height @block_height end |
Class Method Details
.from_model(historical_balance_model) ⇒ HistoricalBalance
Converts a Coinbase::Client::HistoricalBalance model to a Coinbase::HistoricalBalance
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/coinbase/historical_balance.rb', line 9 def self.from_model(historical_balance_model) asset = Coinbase::Asset.from_model(historical_balance_model.asset) new( amount: asset.from_atomic_amount(historical_balance_model.amount), block_height: BigDecimal(historical_balance_model.block_height), block_hash: historical_balance_model.block_hash, asset: asset ) end |
Instance Method Details
#inspect ⇒ String
Same as to_s.
49 50 51 |
# File 'lib/coinbase/historical_balance.rb', line 49 def inspect to_s end |
#to_s ⇒ String
Returns a string representation of the HistoricalBalance.
37 38 39 40 41 42 43 44 45 |
# File 'lib/coinbase/historical_balance.rb', line 37 def to_s Coinbase.pretty_print_object( self.class, amount: amount.to_i, block_height: block_height.to_i, block_hash: block_hash, asset: asset ) end |