binToDec 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +85 -0
- metadata +5 -6
- data/doc/user-guide.txt +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cc6f4bc66ab14915ac3bebe36574c7cefd7992e
|
4
|
+
data.tar.gz: e40d5c78ab27a17b8f39542d49d7232c449e2630
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 123f20572e803e224ac8996bb2424f167b46b5f77fe0856f19375d58921f0beea1859a8923c6e031b66027bedd90cd051a4f18b9fae239d12f518d52ee355e1d
|
7
|
+
data.tar.gz: 12c5b9885612870bbd5050a39849d9afc303903a4e62d10636f3572cbdb2ec8858dd2880996eb5fa7989b1015460f76229a48788bf18245eb613af718835987e
|
data/README.md
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# jscals
|
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
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'jscalc'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
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)
|
32
|
+
|
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
|
+
## Usage
|
44
|
+
|
45
|
+
Math.random()
|
46
|
+
|
47
|
+
x = new Date()
|
48
|
+
|
49
|
+
x.getMonth() => 8
|
50
|
+
|
51
|
+
x.getDate() => 26
|
52
|
+
|
53
|
+
x.getDay() => 4
|
54
|
+
|
55
|
+
x.getFullYear() => 13
|
56
|
+
|
57
|
+
x.getHours()
|
58
|
+
|
59
|
+
x.getMinutes()
|
60
|
+
|
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
|
+
|
75
|
+
## Contributing
|
76
|
+
|
77
|
+
Written by Thomas Dowling (tomgdow)
|
78
|
+
|
79
|
+
The National College of Ireland
|
80
|
+
|
81
|
+
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
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tomgdow
|
@@ -10,17 +10,16 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2013-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: ! "An experimetal gem\
|
14
|
-
|
13
|
+
description: ! "An experimetal gem. \nConverts a binary number to a decimal only if
|
14
|
+
the supplied number is binary.\n"
|
15
15
|
email: thomasgdowling@gmail.com
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
18
|
-
extra_rdoc_files:
|
19
|
-
- doc/user-guide.txt
|
18
|
+
extra_rdoc_files: []
|
20
19
|
files:
|
21
20
|
- Rakefile
|
22
21
|
- lib/binToDec.rb
|
23
|
-
-
|
22
|
+
- README.md
|
24
23
|
- test/test_binToDec.rb
|
25
24
|
homepage: http://rubygems.org/gems/binToDec
|
26
25
|
licenses:
|
data/doc/user-guide.txt
DELETED
@@ -1,21 +0,0 @@
|
|
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
|