Sha256: 2dce5f0f0c6899a5aa068bf39bccddbf088f7704397a25aa62e1da05aa6cc823
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
require "ss7/version" module Ss7 def dec2hex(value = String.new) a = value. chomp.to_i result = a.to_s(16).upcase end def dec2bin(value = String.new) a = value. chomp.to_i result = a.to_s(2) end def dec2oct(value = String.new) a = value. chomp.to_i result = a.to_s(8) end def hex2dec(value = String.new) a = value. chomp result = a.to_i(16).to_s end def bin2dec(value = String.new) a = value. chomp result = a.to_i(2).to_s end def oct2dec(value = String.new) a = value. chomp.upcase result = a.to_i(8).to_s end def dec2pc77(value = String.new) result = Array.new #c = String.new a = value.chomp.to_i.to_s(2) b = 14 - a.size unless (b == nil) c = ("0"*b)+a end c.scan(/......./).each { |part| result.push(part.to_i(2)) } result.join('-') end def pc772dec(value = String.new) result = Array.new a = value.chomp a.split('-').each { |part| b = part.to_i.to_s(2) if (b == 7) result.push(b) else siz = 7 - b.size result.push(("0"*siz)+b) end } result.join().to_i(2).to_s end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ss7-1.0.3 | lib/ss7.rb |
ss7-1.0.2 | lib/ss7.rb |
ss7-1.0.1 | lib/ss7.rb |