base_convert 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +31 -0
- data/lib/base_convert.rb +1 -1
- data/lib/base_convert/configuration.rb +5 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e753042b328396548538387c9494a3acf86541d9
|
4
|
+
data.tar.gz: 1c390e5702aaed4264d1910bac2869c7282205cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f62bcf42823b88be9141e42861966d57bfb95192fb5a04b99bb91402b788349c1008d719e942a4012977066e4954ba790f7789378470ce96a1caef471ad27bcd
|
7
|
+
data.tar.gz: 0d1a75b8292188192ec18c95948f3b9c80c1d52f321c00a2df48b9fdce3f28fb36848554210eb92fece961935d6563615cd55be94ca12c55a936ff8bf818ed54
|
data/README.md
CHANGED
@@ -105,6 +105,37 @@ The third way to convert is via the subclass of String, `BaseConvert::Number`:
|
|
105
105
|
digits = ')!@#$%^&'
|
106
106
|
decimal.to_base(8, digits) #=> "!&&&&&"
|
107
107
|
|
108
|
+
## Keys (Symbols)
|
109
|
+
|
110
|
+
Instead of stating the base number, one can use a mnemonic key:
|
111
|
+
|
112
|
+
graph: GRAPH
|
113
|
+
qgraph: QGRAPH
|
114
|
+
word_: WORD_
|
115
|
+
word: WORD
|
116
|
+
unambiguous: UNAMBIGUOUS
|
117
|
+
hexadecimal: 16
|
118
|
+
hex: 16
|
119
|
+
decimal: 10
|
120
|
+
dec: 10
|
121
|
+
octal: 8
|
122
|
+
oct: 8
|
123
|
+
binary: 2
|
124
|
+
|
125
|
+
The mnemonic key has the advantage of especifying both the base number and the digits to be used.
|
126
|
+
Examples:
|
127
|
+
|
128
|
+
> require 'base_convert' # => true
|
129
|
+
> BaseConvert::Number.new('FF', :hex).to_base(:dec) #=> "255"
|
130
|
+
> BaseConvert::Number.new('255', :dec).to_base(:qgraph) #=> "$m"
|
131
|
+
> BaseConvert::Number.new('$m', :qgraph).to_base(:unambiguous) #=> "CX"
|
132
|
+
> BaseConvert::Number.new('CX', :unambiguous).to_base(:oct) #=> "377"
|
133
|
+
> BaseConvert::Number.new('377', :oct).to_base(:hexadecimal) #=> "FF"
|
134
|
+
|
135
|
+
## New in 2.2.0
|
136
|
+
|
137
|
+
I forgot to map the new digit sets added in 2.1.0 to a key, as listed above.
|
138
|
+
|
108
139
|
## New in 2.1.0
|
109
140
|
|
110
141
|
# GRAPH.length == 94
|
data/lib/base_convert.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: base_convert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- carlosjhr64
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
BaseConvert - Number base conversion.
|