Class: AhoyCaptain::ComparisonLinkComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- AhoyCaptain::ComparisonLinkComponent
- Includes:
- CompareMode, RangeOptions, Rangeable
- Defined in:
- app/components/ahoy_captain/comparison_link_component.rb
Instance Attribute Summary collapse
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#title ⇒ Object
readonly
cheating.
Instance Method Summary collapse
-
#initialize(title: "", classes: "btn btn-sm btn-base-100 no-underline hover:bg-base-100") ⇒ ComparisonLinkComponent
constructor
A new instance of ComparisonLinkComponent.
- #options_for_option ⇒ Object
- #render? ⇒ Boolean
Methods included from Rangeable
Methods included from CompareMode
#compare_mode?, #comparison_mode, included
Constructor Details
#initialize(title: "", classes: "btn btn-sm btn-base-100 no-underline hover:bg-base-100") ⇒ ComparisonLinkComponent
Returns a new instance of ComparisonLinkComponent.
12 13 14 |
# File 'app/components/ahoy_captain/comparison_link_component.rb', line 12 def initialize(title: "", classes: "btn btn-sm btn-base-100 no-underline hover:bg-base-100") @classes = classes end |
Instance Attribute Details
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
11 12 13 |
# File 'app/components/ahoy_captain/comparison_link_component.rb', line 11 def classes @classes end |
#title ⇒ Object (readonly)
cheating
17 18 19 |
# File 'app/components/ahoy_captain/comparison_link_component.rb', line 17 def title @title end |
Instance Method Details
#options_for_option ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'app/components/ahoy_captain/comparison_link_component.rb', line 27 def [ (link_to "Custom period", "javascript:customComparisonModal.showModal()", class: selected(:custom)), (link_to "Year-over-year", AhoyCaptain::Engine.routes.url_helpers.root_path(**helpers.search_params.merge(comparison: :year)), class: selected(:year)), (link_to "Previous period", AhoyCaptain::Engine.routes.url_helpers.root_path(**helpers.search_params.merge(comparison: :previous)), class: selected(:previous, :true)), (link_to "Disable Comparison", AhoyCaptain::Engine.routes.url_helpers.root_path(**helpers.search_params.merge(comparison: false))), ].reverse.join.html_safe end |
#render? ⇒ Boolean
23 24 25 |
# File 'app/components/ahoy_captain/comparison_link_component.rb', line 23 def render? comparison_mode.enabled? end |