Sha256: a92a83ff4d13f8990fe192992ecd2585a05a54568f8a72ef37ebf0c1eda09f20

Contents?: true

Size: 590 Bytes

Versions: 1

Compression:

Stored size: 590 Bytes

Contents

# encoding: utf-8

# Numeric
class Numeric
  # return is hex table
  #
  # ==== Examples
  #
  # 65535 to 65536 case
  #
  #   Numeric.to_binary_table(65535, 65536)
  #
  # result
  #
  #   |10digit| 16digit|
  #   |  65535|0000ffff|
  #   |  65536|00010000|
  #
  def self.to_hex_table(from = 1, to = 10)
    ret = []
    size = to.to_s(16).size - 1
    pad = (size / 4 + 1) * 4
    ret << '|10digit|16digit|'
    (from..to).each { |i|ret << "|#{i}|#{i.to_s(16).rjust(pad, '0')}|" }
    joined = ret.join("\n") + "\n"
    joined.justify_table(:right)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.81 lib/open_classes/numeric/to_hex_table.rb