bases 1.0.1 → 1.0.2

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: f4830291e7d2c4316fe6b443135f45cc172d8618
4
- data.tar.gz: 1a558940aed279b82a4cb56b2420b2a4596f906f
3
+ metadata.gz: 09949ca6bf4b1e6442e726203a2aeae222614d51
4
+ data.tar.gz: 0b4081d84df9f903203b62ff9288dc7ed3d96463
5
5
  SHA512:
6
- metadata.gz: a9a8b6f9a710f0a902cb2e39383749e47dfd38bb0fef0e181bfec54d0f02e7813c093ee70d8d41861290402fc205317fca804637459756823968e41630fda506
7
- data.tar.gz: cef55c71bad2e09c961154c2bd030d8e2e518e19b5b1868177e1f011cd9425c3ebec76f3c1d186872d135ac8c537ff4bcabc4716e1357c2657de33d5ed4ad935
6
+ metadata.gz: dfbe2cd859cd229b9120afa16da456e2d888e9c75842cf3475713ab2489ed7bdaeec905f69719893d3c5531a022c2e32e7fc1c0c324a74094c5faef592c592ec
7
+ data.tar.gz: 13606dcf2dfcd180ef186412717ac358b230dfbaa1f00099eb066c049f1db5e541b767e3600d71651b63cd0b2e7df85a444ec97b401209b2ddd870045276705b
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ .ruby-version
@@ -33,11 +33,8 @@ module Bases::Algorithms
33
33
  # The numeric base is the number of digits in the source base.
34
34
  numeric_base = source_base.count
35
35
 
36
- digits_ary.reverse.each.with_index.reduce(0) do |value, (digit, position)|
37
- # The value of `digit` in the source base is simply the index of `digit`
38
- # in the `@source_base` array.
39
- digit_value_in_base10 = source_base.find_index(digit)
40
- value + (digit_value_in_base10 * (numeric_base**position))
36
+ digits_ary.reduce(0) do |acc, digit|
37
+ source_base.find_index(digit) + numeric_base * acc
41
38
  end
42
39
  end
43
40
  end
@@ -149,7 +149,7 @@ class Bases::Number
149
149
  private
150
150
 
151
151
  def native_ruby_base?(base)
152
- base.is_a?(Fixnum) && base.between?(2, 36)
152
+ base.is_a?(Integer) && base.between?(2, 36)
153
153
  end
154
154
 
155
155
  # A facility method for accessing the `Algorithms` module.
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Bases
4
4
  # The version of the Bases gem.
5
- VERSION = '1.0.1'
5
+ VERSION = '1.0.2'
6
6
  end
@@ -104,23 +104,6 @@ class NumberTest < Minitest::Test
104
104
  assert_equal 0, n('').in_base(10).to_i
105
105
  end
106
106
 
107
- def test_bignums_are_supported
108
- value = n('//////////////').in_base(BASE64).to_i
109
- assert_instance_of Bignum, value
110
-
111
- # MD5 are hex numbers, very big ones too!
112
- hex = Digest::MD5.hexdigest('foo bar')
113
-
114
- # They convert easily to bignums...
115
- assert_instance_of Bignum, n(hex).in_base(16).to_i
116
-
117
- # ...and to base 3 numbers (check that the resulting number is composed of
118
- # only the 0, 1 and 2 digits.
119
- binary_digits = n(hex).in_base(16).to_base(3)
120
- .split('').uniq.map(&:to_i).sort
121
- assert_equal [0, 1, 2], binary_digits
122
- end
123
-
124
107
  def test_to_base_outputting_an_array
125
108
  assert_equal %w(b a b a), n(10).to_base([:a, :b], array: true)
126
109
  assert_equal %w(1 0), n(2).to_base(2, array: true)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bases
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Leopardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-22 00:00:00.000000000 Z
11
+ date: 2017-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  requirements: []
137
137
  rubyforge_project:
138
- rubygems_version: 2.2.2
138
+ rubygems_version: 2.4.5
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: Convert bases like a mofo.
@@ -145,4 +145,3 @@ test_files:
145
145
  - test/monkeypatches_test.rb
146
146
  - test/number_test.rb
147
147
  - test/test_helper.rb
148
- has_rdoc: