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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6257b71bda4550a74b03522240f2313a0033d6d8
4
- data.tar.gz: 7cb3234969be8002ceccd826d631d8096b001b1d
3
+ metadata.gz: e753042b328396548538387c9494a3acf86541d9
4
+ data.tar.gz: 1c390e5702aaed4264d1910bac2869c7282205cb
5
5
  SHA512:
6
- metadata.gz: 627175f20049ecea98ac7022e4fc737215a4068c1d3e1b211b4e1f6fe305fc6a139169a424b23b29c0b0016416e3484a0393cff4c046f3dff098542142491279
7
- data.tar.gz: a1607a756ef907da773d40b9156cec8e0ad124e4ca0f92a72a0f79c334b03eaeb15580d24105d5957cb77ea8468a0c2615808657f44f57ae192f7680c60ee4e4
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
@@ -1,5 +1,5 @@
1
1
  module BaseConvert
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.0'
3
3
  end
4
4
  require 'base_convert/configuration'
5
5
  require 'base_convert/functions'
@@ -27,8 +27,11 @@ module Configuration
27
27
  }
28
28
 
29
29
  DIGITS = {
30
- :word => WORD,
31
- :qgraph => QGRAPH,
30
+ :graph => GRAPH,
31
+ :qgraph => QGRAPH,
32
+ :word_ => WORD,
33
+ :word => WORD,
34
+ :unambiguous => UNAMBIGUOUS,
32
35
  }
33
36
 
34
37
  end
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.1.0
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-19 00:00:00.000000000 Z
11
+ date: 2017-11-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  BaseConvert - Number base conversion.