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.
-
#native_asset ⇒ Asset
readonly
Gets the native Asset of the Network.
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:, assets:, native_asset_id:, chain_id:) ⇒ Network
constructor
Returns a new Network object.
-
#list_assets ⇒ Array<Asset>
Lists the Assets supported by the Network.
Constructor Details
#initialize(network_id:, display_name:, protocol_family:, is_testnet:, assets:, native_asset_id:, chain_id:) ⇒ Network
Returns a new Network object.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/coinbase/network.rb', line 18 def initialize(network_id:, display_name:, protocol_family:, is_testnet:, assets:, native_asset_id:, chain_id:) @network_id = network_id @display_name = display_name @protocol_family = protocol_family @is_testnet = is_testnet @chain_id = chain_id @asset_map = {} assets.each do |asset| @asset_map[asset.asset_id] = asset end raise ArgumentError, 'Native Asset not found' unless @asset_map.key?(native_asset_id) @native_asset = @asset_map[native_asset_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 |
#native_asset ⇒ Asset (readonly)
Gets the native Asset of the Network.
53 54 55 |
# File 'lib/coinbase/network.rb', line 53 def native_asset @native_asset end |
Instance Method Details
#get_asset(asset_id) ⇒ Asset
Gets the Asset with the given ID.
46 47 48 |
# File 'lib/coinbase/network.rb', line 46 def get_asset(asset_id) @asset_map[asset_id] end |
#list_assets ⇒ Array<Asset>
Lists the Assets supported by the Network.
38 39 40 |
# File 'lib/coinbase/network.rb', line 38 def list_assets @asset_map.values end |