binToDec 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/user-guide.txt +21 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f89879084bbe2ef36b8289a3fcc31ceee13132f3
|
4
|
+
data.tar.gz: df4aaf79855e30e2f7c8f50f701f435893e86db0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c03ce2f8782c54a7a9838c46844f31a715857ac96dd6a532957bff25cd84be41847fcebe95e3c84abd13d6022f63bd03f3f9d4129feea2b067627b07f98ab14
|
7
|
+
data.tar.gz: 5a2d2f4ea6e77dc90cc4662f4e1d38d7dabffd6bc5e7cb2a5c3b11ec5b56518963b3967772ae1a902996896416110d37c06fcf4c28e84d7937f3054d546cd1c0
|
data/doc/user-guide.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
binToDec converts a binary number to a decimal only if
|
2
|
+
the argument is binary.
|
3
|
+
|
4
|
+
It should be considered an experimental gem.
|
5
|
+
|
6
|
+
The main function, binToDec(), ins contained within a Converter module.
|
7
|
+
|
8
|
+
Usage:
|
9
|
+
|
10
|
+
Converter.binToDec(1000)
|
11
|
+
Converter.bintoDec(2)
|
12
|
+
|
13
|
+
The program uses the following test to determine if the input is binary:
|
14
|
+
|
15
|
+
arg1.to_s.split(//).map { |i| i.to_i }.find_all { |value| value > 0 }.inject(:*)
|
16
|
+
|
17
|
+
The program uses the following code to convert the input (arg1) to binary.
|
18
|
+
|
19
|
+
result = arg1.to_s.split(//).map { |i| i.to_i }.inject(0) { |accumulator, value| (accumulator + value) * 2 }
|
20
|
+
|
21
|
+
return result/2
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: binToDec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tomgdow
|
@@ -10,14 +10,17 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2013-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: An
|
13
|
+
description: ! "An experimetal gem\n binToDec converts a binary number to a decimal
|
14
|
+
only if the supplied number is binary.\n"
|
14
15
|
email: thomasgdowling@gmail.com
|
15
16
|
executables: []
|
16
17
|
extensions: []
|
17
|
-
extra_rdoc_files:
|
18
|
+
extra_rdoc_files:
|
19
|
+
- doc/user-guide.txt
|
18
20
|
files:
|
19
21
|
- Rakefile
|
20
22
|
- lib/binToDec.rb
|
23
|
+
- doc/user-guide.txt
|
21
24
|
- test/test_binToDec.rb
|
22
25
|
homepage: http://rubygems.org/gems/binToDec
|
23
26
|
licenses:
|