Sha256: f3c0d38bd9573ae8998e4b09c09693791fffd0443b1f87448609527f1fe249e0

Contents?: true

Size: 545 Bytes

Versions: 70

Compression:

Stored size: 545 Bytes

Contents

# encoding: utf-8

# Numeric
class Numeric
  # return is oct table
  #
  # ==== Examples
  #
  # 65535 to 65536 case
  #
  #   Numeric.to_oct_table(65535, 65536)
  #
  # result
  #
  #   |10digit|8digit|
  #   |  65535|177777|
  #   |  65536|200000|
  #
  def self.to_oct_table(from = 1, to = 10)
    ret = []
    size = to.to_s(8).size
    ret << '|10digit|8digit|'
    (from..to).each { |i|ret << "|#{i}|#{i.to_s(8).rjust(size, '0')}|" }
    joined = ret.join("\n") + "\n"
    joined.justify_table(:right)
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.151 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.150 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.149 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.148 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.147 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.146 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.145 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.144 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.143 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.142 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.141 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.140 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.139 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.138 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.137 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.136 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.135 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.134 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.133 lib/open_classes/numeric/to_oct_table.rb
tbpgr_utils-0.0.132 lib/open_classes/numeric/to_oct_table.rb