Class: Solrengine::Ui::AddressComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Solrengine::Ui::AddressComponent
- Defined in:
- app/components/solrengine/ui/address_component.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#copyable ⇒ Object
readonly
Returns the value of attribute copyable.
-
#explorer ⇒ Object
readonly
Returns the value of attribute explorer.
-
#network ⇒ Object
readonly
Returns the value of attribute network.
Instance Method Summary collapse
- #explorer_url ⇒ Object
-
#initialize(address:, copyable: true, explorer: false, network: "mainnet-beta") ⇒ AddressComponent
constructor
A new instance of AddressComponent.
- #truncated_address ⇒ Object
Constructor Details
#initialize(address:, copyable: true, explorer: false, network: "mainnet-beta") ⇒ AddressComponent
Returns a new instance of AddressComponent.
8 9 10 11 12 13 |
# File 'app/components/solrengine/ui/address_component.rb', line 8 def initialize(address:, copyable: true, explorer: false, network: "mainnet-beta") @address = address @copyable = copyable @explorer = explorer @network = network end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
6 7 8 |
# File 'app/components/solrengine/ui/address_component.rb', line 6 def address @address end |
#copyable ⇒ Object (readonly)
Returns the value of attribute copyable.
6 7 8 |
# File 'app/components/solrengine/ui/address_component.rb', line 6 def copyable @copyable end |
#explorer ⇒ Object (readonly)
Returns the value of attribute explorer.
6 7 8 |
# File 'app/components/solrengine/ui/address_component.rb', line 6 def explorer @explorer end |
#network ⇒ Object (readonly)
Returns the value of attribute network.
6 7 8 |
# File 'app/components/solrengine/ui/address_component.rb', line 6 def network @network end |
Instance Method Details
#explorer_url ⇒ Object
21 22 23 24 25 26 27 |
# File 'app/components/solrengine/ui/address_component.rb', line 21 def explorer_url if network == "mainnet-beta" "https://solscan.io/account/#{address}" else "https://explorer.solana.com/address/#{address}?cluster=#{network}" end end |
#truncated_address ⇒ Object
15 16 17 18 19 |
# File 'app/components/solrengine/ui/address_component.rb', line 15 def truncated_address return "" if address.nil? || address.length < 8 "#{address[0..3]}...#{address[-4..]}" end |