Sha256: 7e4e73ec8166c809e0ff49f2b34edc2a7cc8cf92a8cd83655117f0255918da44
Contents?: true
Size: 583 Bytes
Versions: 21
Compression:
Stored size: 583 Bytes
Contents
module Ruby2JS class Converter # (int 1) # (float 1.1) # (str "1")) handle :str do |value| put value.inspect end handle :int, :float do |value| put number_format(value) end handle :octal do |value| put '0' + number_format(value.to_s(8)) end def number_format(number) return number.to_s unless es2021 parts = number.to_s.split('.') parts[0] = parts[0].gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1_") parts[1] = parts[1].gsub(/(\d\d\d)(?=\d)/, "\\1_") if parts[1] parts.join('.') end end end
Version data entries
21 entries across 21 versions & 1 rubygems