Class: Solrengine::Ui::ExplorerLinkComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Solrengine::Ui::ExplorerLinkComponent
- Defined in:
- app/components/solrengine/ui/explorer_link_component.rb
Instance Attribute Summary collapse
-
#network ⇒ Object
readonly
Returns the value of attribute network.
-
#truncate ⇒ Object
readonly
Returns the value of attribute truncate.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #display_text ⇒ Object
- #explorer_url ⇒ Object
-
#initialize(value:, type: :address, network: "mainnet-beta", truncate: true) ⇒ ExplorerLinkComponent
constructor
A new instance of ExplorerLinkComponent.
Constructor Details
#initialize(value:, type: :address, network: "mainnet-beta", truncate: true) ⇒ ExplorerLinkComponent
Returns a new instance of ExplorerLinkComponent.
8 9 10 11 12 13 |
# File 'app/components/solrengine/ui/explorer_link_component.rb', line 8 def initialize(value:, type: :address, network: "mainnet-beta", truncate: true) @value = value @type = type @network = network @truncate = truncate end |
Instance Attribute Details
#network ⇒ Object (readonly)
Returns the value of attribute network.
6 7 8 |
# File 'app/components/solrengine/ui/explorer_link_component.rb', line 6 def network @network end |
#truncate ⇒ Object (readonly)
Returns the value of attribute truncate.
6 7 8 |
# File 'app/components/solrengine/ui/explorer_link_component.rb', line 6 def truncate @truncate end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'app/components/solrengine/ui/explorer_link_component.rb', line 6 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'app/components/solrengine/ui/explorer_link_component.rb', line 6 def value @value end |
Instance Method Details
#display_text ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/components/solrengine/ui/explorer_link_component.rb', line 15 def display_text if truncate && value.length > 12 "#{value[0..7]}...#{value[-4..]}" else value end end |
#explorer_url ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/solrengine/ui/explorer_link_component.rb', line 23 def explorer_url if network == "mainnet-beta" case type when :address "https://solscan.io/account/#{value}" when :tx "https://solscan.io/tx/#{value}" end else path = type == :tx ? "tx" : "address" "https://explorer.solana.com/#{path}/#{value}?cluster=#{network}" end end |