Sha256: 5f44463b3cf631b10d6c4f9586f459f771a65aa1fef7cb7b5a47f23dd7b56d80

Contents?: true

Size: 411 Bytes

Versions: 1

Compression:

Stored size: 411 Bytes

Contents

require "numerology/version"

module Numerology
  def format_like(example)
    return self.separate_thousands(example[-4]) if example =~ /(\D)\d{3}$/
  end

  def separate_thousands(separator)
    self.to_s =~ /([^\.]*)(\..*)?/
    int, dec = $1.reverse, $2 ? $2 : ""
    while int.gsub!(/(,|\.|^)(\d{3})(\d)/, '\1\2'+separator+'\3')
    end
    int.reverse + dec
  end
end

Numeric.send(:include, ::Numerology)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
numerology-0.0.1 lib/numerology.rb