Class: AhoyCaptain::TooltipComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/ahoy_captain/tooltip_component.rb

Instance Method Summary collapse

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

#abbreviateObject



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