binToDec 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -55
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7cc6f4bc66ab14915ac3bebe36574c7cefd7992e
4
- data.tar.gz: e40d5c78ab27a17b8f39542d49d7232c449e2630
3
+ metadata.gz: bd7589ee2f37f6235a26c4b819399715d2149a5e
4
+ data.tar.gz: a0cddca7d6215cc9055091579de232394d92caa1
5
5
  SHA512:
6
- metadata.gz: 123f20572e803e224ac8996bb2424f167b46b5f77fe0856f19375d58921f0beea1859a8923c6e031b66027bedd90cd051a4f18b9fae239d12f518d52ee355e1d
7
- data.tar.gz: 12c5b9885612870bbd5050a39849d9afc303903a4e62d10636f3572cbdb2ec8858dd2880996eb5fa7989b1015460f76229a48788bf18245eb613af718835987e
6
+ metadata.gz: 766213a9a8470ef7b567fde6c2f2c0a1f9e0a3e3b3cfcf4643fa95b9519e5d02edd7857c199bdb2d209cc5201cf82f67406d6a7439095346c564117f4cfff345
7
+ data.tar.gz: 7952295fbc0bdd2f9f40cd2e4b0a5e3bdbbe55b550e0bc0b5d9a5c28f043ee20c9c5d88f9a9ad9f5b17fb9ddc1a92cf9d994b82dad1fad68f6078202ad89e6b3
data/README.md CHANGED
@@ -1,14 +1,15 @@
1
- # jscals
1
+ # Binary to Decimal Conversion (binToDec)
2
2
 
3
- jscalc is a calculator written in JavaScript/CSS3
4
- As well as having basic calculator functions, many in-build JavaScript
5
- functions (such as Math.random ()) are available
3
+ binToDec is written in Ruby, and converts a binary number to a decimal only if
4
+ the argument is binary.
5
+
6
+ It should be considered an experimental gem.
6
7
 
7
8
  ## Installation
8
9
 
9
10
  Add this line to your application's Gemfile:
10
11
 
11
- gem 'jscalc'
12
+ gem 'binToDec'
12
13
 
13
14
  And then execute:
14
15
 
@@ -16,70 +17,31 @@ And then execute:
16
17
 
17
18
  Or install it yourself as:
18
19
 
19
- $ gem install jscalc
20
-
21
- Add the following HTML code to the page where you want the calculator to appear
22
-
23
- **"<div id = "myCalculator">
24
- <div id="panelDiv">
25
- <input type ="text" id = "calcPanel" />
26
- </div> <!--End panelDiv-->
27
- </div><!--End myCalculator Div-->"**
28
-
29
-
30
- Add the following to the bottom of application.html.erb (the script file must render in the body
31
- section of the HTML page, not in the head section)
20
+ $ gem install binToDec
32
21
 
33
- **<%= javascript_include_tag "jscalc.js" %>**
34
-
35
- Add the following line to the head section of application.html.erb
36
-
37
- **<%= stylesheet_link_tag "jscalc.css" %>**
38
-
39
- **TO MAKE THE CALCULATOR DRAGGABLE**, ensure that jQuery-ui is installed or add the following files to the head section of application.html.erb BEFORE the stylesheet link tag.
40
-
41
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
42
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
43
22
  ## Usage
44
23
 
45
- Math.random()
46
-
47
- x = new Date()
24
+ Converter.binToDec(1000)
48
25
 
49
- x.getMonth() => 8
26
+ Converter.bintoDec(2)
50
27
 
51
- x.getDate() => 26
28
+ ## Basis
29
+ The program uses the following test to determine if the input is binary:
52
30
 
53
- x.getDay() => 4
31
+ arg1.to\_s.split(//).map { |i| i.to\_i }.find\_all { |value| value > 0 }.inject(:*)
54
32
 
55
- x.getFullYear() => 13
56
33
 
57
- x.getHours()
34
+ The program uses the following code to convert the input (arg1) to binary.
58
35
 
59
- x.getMinutes()
36
+ arg1.to\_s.split(//).map { |i| i.to\_i }.inject(0) { |accumulator, value| (accumulator + value) * 2 }
37
+
38
+ return result/2
60
39
 
61
- x.getSeconds()
62
-
63
- x.getMilliseconds();
64
-
65
- Math.round();
66
-
67
- navigator.appName
68
-
69
- parseInt(1101,2)
70
-
71
- isNaN(2)
72
-
73
- typeof(2)
74
40
 
75
41
  ## Contributing
76
42
 
77
- Written by Thomas Dowling (tomgdow)
43
+ Written by Thomas Dowling ([tomgdow](http://mathematica.stackexchange.com/users/106/tomd))
78
44
 
79
45
  The National College of Ireland
80
46
 
81
47
  thomasgdowling@gmail.com
82
-
83
-
84
-
85
-
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
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - tomgdow