Class: Coinbase::Network
- Inherits:
-
Object
- Object
- Coinbase::Network
- Defined in:
- lib/coinbase/network.rb
Overview
A blockchain network.
Instance Attribute Summary collapse
-
#chain_id ⇒ Object
readonly
Returns the value of attribute chain_id.
Instance Method Summary collapse
-
#get_asset(asset_id) ⇒ Asset
Gets the Asset with the given ID.
-
#initialize(network_id:, display_name:, protocol_family:, is_testnet:, native_asset_id:, chain_id:) ⇒ Network
constructor
Returns a new Network object.
-
#native_asset ⇒ Asset
Gets the native Asset of the Network.
Constructor Details
#initialize(network_id:, display_name:, protocol_family:, is_testnet:, native_asset_id:, chain_id:) ⇒ Network
Returns a new Network object. Do not use this method directly. Instead, use the Network constants defined in the Coinbase module.
17 18 19 20 21 22 23 24 |
# File 'lib/coinbase/network.rb', line 17 def initialize(network_id:, display_name:, protocol_family:, is_testnet:, native_asset_id:, chain_id:) @network_id = network_id @display_name = display_name @protocol_family = protocol_family @is_testnet = is_testnet @native_asset_id = native_asset_id @chain_id = chain_id end |
Instance Attribute Details
#chain_id ⇒ Object (readonly)
Returns the value of attribute chain_id.
6 7 8 |
# File 'lib/coinbase/network.rb', line 6 def chain_id @chain_id end |
Instance Method Details
#get_asset(asset_id) ⇒ Asset
Gets the Asset with the given ID.
30 31 32 |
# File 'lib/coinbase/network.rb', line 30 def get_asset(asset_id) Asset.fetch(@network_id, asset_id) end |
#native_asset ⇒ Asset
Gets the native Asset of the Network.
37 38 39 |
# File 'lib/coinbase/network.rb', line 37 def native_asset @native_asset ||= get_asset(@native_asset_id) end |