Skip to content

Instantly share code, notes, and snippets.

@louishuyng
Last active November 2, 2023 08:24
Show Gist options
  • Save louishuyng/cc74a053e0f34159a0277c9bf876588c to your computer and use it in GitHub Desktop.
Save louishuyng/cc74a053e0f34159a0277c9bf876588c to your computer and use it in GitHub Desktop.
Number To Social
def number_to_social(number)
return number_with_delimiter(number) if number < 10_000
number_to_human(number,
precision: 1,
round_mode: :down,
significant: false,
format: "%n%u",
units: {thousand: "K", million: "M", billion: "B"}
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment