electric 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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -2
  3. data/lib/electric/ohm.rb +2 -2
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02742beca6cabb448b85703e30cdc829008f4129
4
- data.tar.gz: 7a471903b9aa74579dbb9db0f2ce458d2e8167e3
3
+ metadata.gz: 35f89c80c18ec3cc1bb84c36880b42c2ab55c0a0
4
+ data.tar.gz: 050c9b402d0b7a7448664818684edd1c5b7446b5
5
5
  SHA512:
6
- metadata.gz: 743679e89445520340da808332e78f63f222fb7aae0b5d5b8e4067ca0bf76eefcc5a323b656259c6f04c639aba3b0041ccc2791de5f90af79a77cfeddd60af1c
7
- data.tar.gz: 7e63781573ee7525f5328555d87b19cb7a25eb445c7b81e4a48733224e23de8482df947b8b01f502ec2115c816166be48a846e409acf91868bbae5a8089dee51
6
+ metadata.gz: faf6ba1905bf0c341b0962c814bc3b396874c4e84a3b99678738481b014da3fdfff690d69a062ef3aafdaf759d515fdf9073f76e24bcf66b0208b7423caf87f6
7
+ data.tar.gz: d10ed648975f54ab0b746a8b1334f40c4ddc84652750cca713d011ce99afc1c34173f8663966a1ab8726b2e8a62b112e143ac78b9eae374768023444119c8ae8
data/README.md CHANGED
@@ -1,11 +1,31 @@
1
1
  ## Ruby Library for electronics
2
2
 
3
3
  ### Resistor Color Code Calculator
4
- Electric::Resistor.new("red", "black", "brown").human_readable
4
+
5
+ Accepts 4 arguments (first 3 bands determine resistor value, 4th band is for tolerance %), though none are required to return a value of 0 ohms. You must preserve order of bands as arguments.
6
+
7
+ resistor = Electric::Resistor.new("red", "black", "brown")
8
+ resistor.value
9
+ => 200
10
+ resistor.tolerance
11
+ => "5%"
12
+ resistor.human_readable
13
+ => "200 ohms, +/- 5%"
5
14
 
6
15
  ### Ohm's Law Calculator
7
- Electric::Ohm.new(:volts => 5, :ohms => 330).current
8
16
 
17
+ Accepts 4 named arguments: "volts", "ohms", "amps", and "watts" in any order. You must provide at least 2 properties to calculate other 2.
18
+
19
+ There are 4 methods that can be called to run calculations: "resistance", "power", "voltage", and "current"
20
+
21
+ Electric::Ohm.new(:volts => 5, :ohms => 330).voltage
22
+ => 5.0
23
+ Electric::Ohm.new(:volts => 5, :ohms => 330).resistance
24
+ => 330.0
25
+ Electric::Ohm.new(:volts => 5, :ohms => 330).current
26
+ => 0.015151515151515152
27
+ Electric::Ohm.new(:volts => 5, :ohms => 330).power
28
+ => 0.07575757575757576
9
29
 
10
30
 
11
31
  More documentation on the way...
data/lib/electric/ohm.rb CHANGED
@@ -48,8 +48,8 @@ module Electric
48
48
  # I * R
49
49
  amps * ohms
50
50
  elsif watts && amps
51
- # P / I^2
52
- watts / (amps * amps)
51
+ # P / I
52
+ watts / amps
53
53
  elsif ohms && watts
54
54
  # sq_root(P * R)
55
55
  sqrt(watts * ohms)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: electric
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
  - JD Warren