Class: AhoyCaptain::TooltipComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- AhoyCaptain::TooltipComponent
- Defined in:
- app/components/ahoy_captain/tooltip_component.rb
Instance Method Summary collapse
- #abbreviate ⇒ Object
-
#initialize(amount:) ⇒ TooltipComponent
constructor
A new instance of TooltipComponent.
Constructor Details
#initialize(amount:) ⇒ TooltipComponent
Returns a new instance of TooltipComponent.
2 3 4 |
# File 'app/components/ahoy_captain/tooltip_component.rb', line 2 def initialize(amount:) @amount = amount end |
Instance Method Details
#abbreviate ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/components/ahoy_captain/tooltip_component.rb', line 6 def abbreviate if amount.to_i >= 1000 number_to_human(amount, format: '%n%u', precision: 2, units: { thousand: 'k', million: 'm', billion: 'b' }) else amount.to_s end end |