eletro 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/eletro.gemspec +7 -2
- data/lib/eletro.rb +3 -0
- data/lib/eletro/capacitor.rb +4 -12
- data/lib/eletro/helpers/color_code.rb +14 -3
- data/lib/eletro/ohm.rb +0 -2
- data/lib/eletro/part.rb +4 -3
- data/lib/eletro/resistor.rb +7 -0
- data/lib/eletro/transistor.rb +37 -1
- data/lib/eletro/wire.rb +68 -0
- data/spec/eletro/capacitor_spec.rb +29 -6
- data/spec/eletro/part_spec.rb +9 -6
- data/spec/eletro/resistor_spec.rb +56 -22
- data/spec/eletro/transistor_spec.rb +66 -0
- data/spec/eletro/wire_spec.rb +26 -0
- metadata +8 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/eletro.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{eletro}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marcos Piccinini"]
|
12
|
-
s.date = %q{2010-11-
|
12
|
+
s.date = %q{2010-11-28}
|
13
13
|
s.default_executable = %q{eletro}
|
14
14
|
s.description = %q{Eletric Stuff, Ohm Law, Resistor Colors, Karnaugh Maps and other gems on Ruby}
|
15
15
|
s.email = %q{x@nofxx.com}
|
@@ -37,12 +37,15 @@ Gem::Specification.new do |s|
|
|
37
37
|
"lib/eletro/resistor.rb",
|
38
38
|
"lib/eletro/source.rb",
|
39
39
|
"lib/eletro/transistor.rb",
|
40
|
+
"lib/eletro/wire.rb",
|
40
41
|
"spec/colour_test",
|
41
42
|
"spec/eletro/capacitor_spec.rb",
|
42
43
|
"spec/eletro/ohm_spec.rb",
|
43
44
|
"spec/eletro/part_spec.rb",
|
44
45
|
"spec/eletro/resistor_spec.rb",
|
45
46
|
"spec/eletro/source_spec.rb",
|
47
|
+
"spec/eletro/transistor_spec.rb",
|
48
|
+
"spec/eletro/wire_spec.rb",
|
46
49
|
"spec/eletro_spec.rb",
|
47
50
|
"spec/spec_helper.rb"
|
48
51
|
]
|
@@ -57,7 +60,9 @@ Gem::Specification.new do |s|
|
|
57
60
|
"spec/eletro/capacitor_spec.rb",
|
58
61
|
"spec/eletro/ohm_spec.rb",
|
59
62
|
"spec/eletro/resistor_spec.rb",
|
63
|
+
"spec/eletro/transistor_spec.rb",
|
60
64
|
"spec/eletro/part_spec.rb",
|
65
|
+
"spec/eletro/wire_spec.rb",
|
61
66
|
"spec/eletro_spec.rb"
|
62
67
|
]
|
63
68
|
|
data/lib/eletro.rb
CHANGED
data/lib/eletro/capacitor.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
module Eletro
|
4
4
|
|
5
5
|
class Capacitor < Part
|
6
|
+
|
6
7
|
attr_accessor :polarized
|
7
8
|
|
8
9
|
include ColorCode
|
@@ -17,11 +18,9 @@ module Eletro
|
|
17
18
|
m = mult[m[0]]
|
18
19
|
else
|
19
20
|
st, nd, m = txt.split(//)
|
20
|
-
m ||= 0
|
21
21
|
m = m.to_i #(10**-(m.to_i))
|
22
22
|
end
|
23
|
-
|
24
|
-
num
|
23
|
+
("#{st}#{nd}#{'0' * m}").to_f * mult['p']
|
25
24
|
end
|
26
25
|
|
27
26
|
def unit
|
@@ -29,7 +28,7 @@ module Eletro
|
|
29
28
|
end
|
30
29
|
|
31
30
|
def mult
|
32
|
-
{ '
|
31
|
+
{ 'u' => 10e-6, 'n' => 10e-9, 'p' => 10e-12 }
|
33
32
|
end
|
34
33
|
|
35
34
|
def format
|
@@ -37,14 +36,7 @@ module Eletro
|
|
37
36
|
mult.keys.reverse.each do |k|
|
38
37
|
m = k if value >= mult[k]
|
39
38
|
end
|
40
|
-
|
41
|
-
# "%g" % @value
|
42
|
-
# elsif value < 1000000
|
43
|
-
# "%gk" % (@value/1000)
|
44
|
-
# else
|
45
|
-
# "%gm" % (@value/1000000)
|
46
|
-
# end
|
47
|
-
out = "%g#{m}#{unit}" % (value/mult[m]).round
|
39
|
+
out = "%g#{m}#{unit}" % (value/mult[m]) #.round
|
48
40
|
out += " ± #{@precision}%" if @precision
|
49
41
|
out
|
50
42
|
end
|
@@ -42,6 +42,9 @@ module Eletro
|
|
42
42
|
CODE.index(char.downcase.to_sym)
|
43
43
|
end
|
44
44
|
|
45
|
+
#
|
46
|
+
# Converts the color code value to numeric
|
47
|
+
#
|
45
48
|
def color2value chars
|
46
49
|
out = calc(chars[0])
|
47
50
|
out = (out.to_s + calc(chars[1]).to_s).to_f
|
@@ -54,16 +57,24 @@ module Eletro
|
|
54
57
|
out
|
55
58
|
end
|
56
59
|
|
60
|
+
#
|
61
|
+
# Converts a numeric value into a color code array
|
62
|
+
#
|
63
|
+
# st nd rest (multiplier)
|
64
|
+
# 123.0 -> ['1', '2', '3.0']
|
65
|
+
#
|
66
|
+
#
|
57
67
|
def value2color value
|
58
68
|
st, nd, *rest = value.to_s.split(//)
|
59
69
|
out = [CODE[st.to_i], CODE[nd.to_i]]
|
60
|
-
|
61
|
-
index ||= (value ** 0.1).round
|
62
|
-
out << CODE[index]
|
70
|
+
out << CODE[value.to_i.to_s.size-2]
|
63
71
|
out
|
64
72
|
end
|
65
73
|
|
66
74
|
|
75
|
+
#
|
76
|
+
# Creates a coloured version to print on stdout
|
77
|
+
#
|
67
78
|
def rgblize color
|
68
79
|
s = case color.to_s.downcase.to_sym
|
69
80
|
when :k then "\e[40m"
|
data/lib/eletro/ohm.rb
CHANGED
data/lib/eletro/part.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Eletro
|
2
2
|
|
3
3
|
class Part
|
4
|
-
attr_accessor :value, :unit, :p0, :p1, :v
|
4
|
+
attr_accessor :value, :unit, :p0, :p1, :v, :i
|
5
5
|
|
6
6
|
def p0
|
7
7
|
@p0 ||= :gnd
|
@@ -59,8 +59,9 @@ module Eletro
|
|
59
59
|
respond_to?(txt) ? send(args.join) : nil
|
60
60
|
end
|
61
61
|
else
|
62
|
-
|
63
|
-
"
|
62
|
+
super
|
63
|
+
# raise NoMethodError.new("undefined method `#{args.join}' " +
|
64
|
+
# "for #{self.inspect}:#{self.class.name}")
|
64
65
|
end
|
65
66
|
|
66
67
|
end
|
data/lib/eletro/resistor.rb
CHANGED
data/lib/eletro/transistor.rb
CHANGED
@@ -1,8 +1,44 @@
|
|
1
1
|
module Eletro
|
2
2
|
|
3
|
+
|
3
4
|
class Transistor < Part
|
4
5
|
|
5
|
-
|
6
|
+
attr_accessor :i, :name, :ri, :hfe
|
7
|
+
|
8
|
+
def initialize *args
|
9
|
+
params, txt = *args.partition { |a| a.is_a?(Hash) }
|
10
|
+
@npn = params[0] && params[0][:type] == "pnp" ? false : true
|
11
|
+
@name = txt.join
|
12
|
+
end
|
13
|
+
|
14
|
+
def w
|
15
|
+
v * i
|
16
|
+
end
|
17
|
+
|
18
|
+
def npn?
|
19
|
+
@npn
|
20
|
+
end
|
21
|
+
|
22
|
+
def pnp?
|
23
|
+
!@npn
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def self.pnp
|
28
|
+
new(:type => "pnp")
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.npn
|
32
|
+
new
|
33
|
+
end
|
34
|
+
|
35
|
+
# Theory of thermal resistance
|
36
|
+
# Tj = Ta + Rth(j-a) * P
|
37
|
+
#
|
38
|
+
# Ta -> Ambient temp
|
39
|
+
# Rth(j-a) -> Thermal resistance inbetween Junction and Ambient
|
40
|
+
|
41
|
+
|
6
42
|
end
|
7
43
|
|
8
44
|
end
|
data/lib/eletro/wire.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
module Eletro
|
2
|
+
|
3
|
+
|
4
|
+
class Wire < Part
|
5
|
+
MULT = { :mil => 2.54e-3, :mm => 0.1, :um => 1e-4 }
|
6
|
+
TEMP = 25
|
7
|
+
RHO = 1.7e-6
|
8
|
+
ALPHA = 3.9e-3 # //ohm/ohm/C
|
9
|
+
|
10
|
+
LEN = 1
|
11
|
+
TEMP_RISE = 10
|
12
|
+
THICKNESS = 0.1
|
13
|
+
|
14
|
+
|
15
|
+
IRISE = {
|
16
|
+
:internal => { :k => 0.048, :b => 0.44, :c => 0.725 },
|
17
|
+
:external => { :k => 0.024, :b => 0.44, :c => 0.725 }
|
18
|
+
# return Math.pow((current/(k*Math.pow(rise,b))),1/c)
|
19
|
+
|
20
|
+
}
|
21
|
+
|
22
|
+
attr_accessor :width, :thickness, :length
|
23
|
+
|
24
|
+
def spacing
|
25
|
+
case v
|
26
|
+
when 0..100 then [0.005, 0.004]
|
27
|
+
when 101..300 then [0.015, 0.008]
|
28
|
+
when 301..500 then [0.030, 0.010]
|
29
|
+
else
|
30
|
+
0.030 * ( v / 500)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def area(place)
|
35
|
+
@area = (i / IRISE[place][:k] * (TEMP_RISE ** IRISE[place][:b])) ** (1/IRISE[place][:c])
|
36
|
+
end
|
37
|
+
|
38
|
+
def tk
|
39
|
+
@tk || THICKNESS
|
40
|
+
end
|
41
|
+
|
42
|
+
def calc(pos = :external)
|
43
|
+
area = area(pos) #, @temp_rise || TEMP_RISE) # //mils^2
|
44
|
+
area = area * 2.54 * 2.54 / 1e6 # //mil^2 to cm^2
|
45
|
+
wi = area / tk
|
46
|
+
wi = wi / MULT[@mult || :mm]
|
47
|
+
tval = 1 * (@temp || TEMP) + 1 * TEMP_RISE
|
48
|
+
ri = (RHO * LEN / area) * (1 + ALPHA * (tval-25))
|
49
|
+
vi = ri * i
|
50
|
+
pi = i * i * ri
|
51
|
+
|
52
|
+
# ae = area
|
53
|
+
# ae = ae * 2.54 * 2.54 / 1e6 # //mil^2 to cm^2
|
54
|
+
# we = ae/tk # //cm
|
55
|
+
# we = we/document.getElementById("twSelect3").value # //user units
|
56
|
+
# re = (rho*len/ae)*(1+alpha*(tval-25))
|
57
|
+
# ve = re*i
|
58
|
+
# pe = i*i*re
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
def size
|
63
|
+
calc
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -12,17 +12,40 @@ describe "Eletro::Capacitor" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should instantiate 47" do
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
c = Capacitor.new("47")
|
16
|
+
c.value.should be_within(10e-10).of(4.7e-10)
|
17
|
+
c.format.should eql("47pF")
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should instantiate 102" do
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
c = Capacitor.new("102")
|
22
|
+
c.value.should be_within(10e-10).of(1.0e-8)
|
23
|
+
c.format.should eql("1nF")
|
24
24
|
end
|
25
25
|
|
26
|
+
it "should instantiate 472" do
|
27
|
+
c = Capacitor.new("472")
|
28
|
+
c.value.should be_within(10e-10).of(4.7e-8)
|
29
|
+
c.format.should eql("4.7nF")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should instantiate 473" do
|
33
|
+
c = Capacitor.new("473")
|
34
|
+
c.value.should be_within(10e-10).of(4.7e-7)
|
35
|
+
c.format.should eql("47nF")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should instantiate 10nF" do
|
39
|
+
c = Capacitor.new("103")
|
40
|
+
c.value.should be_within(10e-10).of(1.0e-7)
|
41
|
+
c.format.should eql("10nF")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should instantiate 220nF" do
|
45
|
+
c = Capacitor.new("224")
|
46
|
+
c.value.should be_within(10e-10).of(2.2e-6)
|
47
|
+
c.format.should eql("220nF")
|
48
|
+
end
|
26
49
|
|
27
50
|
end
|
28
51
|
|
data/spec/eletro/part_spec.rb
CHANGED
@@ -2,21 +2,24 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
3
3
|
describe "Eletro::Part" do
|
4
4
|
|
5
|
-
let(:
|
5
|
+
let(:part) { Part.new}
|
6
6
|
|
7
7
|
it "should have pins" do
|
8
|
-
|
8
|
+
part.p0.should eql(:gnd)
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should get dynamic" do
|
12
|
-
|
12
|
+
part.p99.should be_nil
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should set dynamic" do
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
part.p99.should be_nil
|
17
|
+
part.p99 = :fu
|
18
|
+
part.p99.should eql('fu')
|
19
19
|
end
|
20
20
|
|
21
|
+
it "should return NoMethodErrors" do
|
22
|
+
lambda { part.blablabla }.should raise_error
|
23
|
+
end
|
21
24
|
|
22
25
|
end
|
@@ -5,41 +5,75 @@ describe "Eletro::Resistor" do
|
|
5
5
|
|
6
6
|
let(:rs) { Resistor.new }
|
7
7
|
|
8
|
+
it "should have a fancy instantiate method" do
|
9
|
+
200.R.should eql(Resistor.new(220))
|
10
|
+
end
|
11
|
+
|
8
12
|
describe "Value" do
|
9
13
|
|
10
|
-
it "should instantiate 220 ohms" do
|
14
|
+
it "should instantiate 220 string ohms" do
|
11
15
|
r = Resistor.new("220")
|
12
|
-
r.value.should be_within(
|
16
|
+
r.value.should be_within(0.1).of(220.0)
|
17
|
+
r.format.should eql("220Ω")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should instantiate 220 integer ohms" do
|
21
|
+
r = Resistor.new(220)
|
22
|
+
r.value.should be_within(0.1).of(220.0)
|
13
23
|
r.format.should eql("220Ω")
|
14
24
|
end
|
15
25
|
|
16
26
|
it "should instantiate 100R ohms" do
|
17
27
|
r = Resistor.new("100R")
|
18
|
-
r.value.should be_within(
|
28
|
+
r.value.should be_within(0.1).of(100.0)
|
19
29
|
r.format.should eql("100Ω")
|
30
|
+
Resistor.new("100").colors.join.should eql("bkb")
|
20
31
|
end
|
21
32
|
|
22
33
|
it "should instantiate 1k ohms" do
|
23
|
-
r = Resistor.new("
|
34
|
+
r = Resistor.new("1000.0")
|
24
35
|
r.value.should be_within(1000.0).of(0.1)
|
25
36
|
r.format.should eql("1kΩ")
|
37
|
+
Resistor.new("1k").colors.join.should eql("bkr")
|
26
38
|
end
|
27
39
|
|
28
|
-
it "should instantiate
|
29
|
-
r = Resistor.new("
|
30
|
-
r.value.should be_within(
|
31
|
-
r.format.should eql("
|
40
|
+
it "should instantiate 10k ohms" do
|
41
|
+
r = Resistor.new("BKO")
|
42
|
+
r.value.should be_within(0.1).of(10000)
|
43
|
+
r.format.should eql("10kΩ")
|
44
|
+
Resistor.new("10k").colors.join.should eql("bko")
|
32
45
|
end
|
33
46
|
|
34
|
-
it "should instantiate
|
47
|
+
it "should instantiate 100k ohms" do
|
48
|
+
r = Resistor.new("BKY")
|
49
|
+
r.value.should be_within(0.1).of(100000)
|
50
|
+
r.format.should eql("100kΩ")
|
51
|
+
Resistor.new("100k").colors.join.should eql("bky")
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should instantiate 1m ohms" do
|
55
|
+
r = Resistor.new("BKG")
|
56
|
+
r.value.should be_within(0.1).of(1000000)
|
57
|
+
r.format.should eql("1mΩ")
|
58
|
+
Resistor.new("1m").colors.join.should eql("bkg")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should instantiate 10m ohms" do
|
62
|
+
r = Resistor.new("BKU")
|
63
|
+
r.value.should be_within(0.1).of(10000000)
|
64
|
+
r.format.should eql("10mΩ")
|
65
|
+
Resistor.new("10m").colors.join.should eql("bku")
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should instantiate 1.1k ohms" do
|
35
69
|
r = Resistor.new("1100.0")
|
36
|
-
r.value.should be_within(
|
70
|
+
r.value.should be_within(0.1).of(1100.1)
|
37
71
|
r.format.should eql("1.1kΩ")
|
38
72
|
end
|
39
73
|
|
40
|
-
it "should instantiate 1k ohms" do
|
74
|
+
it "should instantiate 1.1k ohms" do
|
41
75
|
r = Resistor.new("BBR")
|
42
|
-
r.value.should be_within(
|
76
|
+
r.value.should be_within(0.1).of(1100)
|
43
77
|
r.format.should eql("1.1kΩ")
|
44
78
|
end
|
45
79
|
|
@@ -57,7 +91,7 @@ describe "Eletro::Resistor" do
|
|
57
91
|
|
58
92
|
it "should instantiate 1m5 ohms" do
|
59
93
|
r = Resistor.new("1m5")
|
60
|
-
r.value.should be_within(
|
94
|
+
r.value.should be_within(0.00001).of(1500000.0)
|
61
95
|
r.format.should eql("1.5mΩ")
|
62
96
|
end
|
63
97
|
|
@@ -93,52 +127,52 @@ describe "Eletro::Resistor" do
|
|
93
127
|
|
94
128
|
end
|
95
129
|
|
96
|
-
describe "
|
130
|
+
describe "Color Code" do
|
97
131
|
|
98
132
|
it "should instantiate 3 chars" do
|
99
133
|
r = Resistor.new("BKR")
|
100
|
-
r.value.should be_within(
|
134
|
+
r.value.should be_within(0.01).of(1000.0)
|
101
135
|
r.format.should eql("1kΩ")
|
102
136
|
end
|
103
137
|
|
104
138
|
it "should instantiate 3 chars" do
|
105
139
|
r = Resistor.new("BKO")
|
106
|
-
r.value.should be_within(
|
140
|
+
r.value.should be_within(0.01).of(10000.0)
|
107
141
|
r.format.should eql("10kΩ")
|
108
142
|
end
|
109
143
|
|
110
144
|
it "should instantiate 3 chars" do
|
111
145
|
r = Resistor.new("YVR")
|
112
|
-
r.value.should be_within(
|
146
|
+
r.value.should be_within(0.01).of(4700.0)
|
113
147
|
r.format.should eql("4.7kΩ")
|
114
148
|
end
|
115
149
|
|
116
150
|
it "should instantiate 3 chars" do
|
117
151
|
r = Resistor.new("YVR")
|
118
|
-
r.value.should be_within(
|
152
|
+
r.value.should be_within(0.01).of(4700.0)
|
119
153
|
r.format.should eql("4.7kΩ")
|
120
154
|
end
|
121
155
|
|
122
156
|
it "should instantiate 4 chars" do
|
123
157
|
r = Resistor.new("WWRS")
|
124
|
-
r.value.should be_within(
|
158
|
+
r.value.should be_within(0.01).of(9900.0)
|
125
159
|
r.format.should eql("9.9kΩ ± 10%")
|
126
160
|
end
|
127
161
|
|
128
162
|
it "should instantiate 4 chars" do
|
129
163
|
r = Resistor.new("BKRL")
|
130
|
-
r.value.should be_within(
|
164
|
+
r.value.should be_within(0.01).of(1000.0)
|
131
165
|
r.format.should eql("1kΩ ± 5%")
|
132
166
|
end
|
133
167
|
|
134
168
|
end
|
135
169
|
|
136
170
|
|
137
|
-
describe "Colors" do
|
171
|
+
describe "Term Colors" do
|
138
172
|
|
139
173
|
it "should print nicely" do
|
140
174
|
r = Resistor.new("BKR")
|
141
|
-
r.value.should be_within(
|
175
|
+
r.value.should be_within(0.01).of(1000.0)
|
142
176
|
r.pretty_output.should eql("1kΩ --\e[0;33mB\e[0m\e[40mK\e[0m\e[41mR\e[0m--")
|
143
177
|
end
|
144
178
|
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
3
|
+
|
4
|
+
describe "Eletro::Transistor" do
|
5
|
+
|
6
|
+
let(:t) { Transistor.new }
|
7
|
+
|
8
|
+
it "should have V" do
|
9
|
+
t.v = 12
|
10
|
+
t.v.should eql(12)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have I" do
|
14
|
+
t.i = 12
|
15
|
+
t.i.should eql(12)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should calculate W" do
|
19
|
+
t.v= 12
|
20
|
+
t.i = 3
|
21
|
+
t.w.should eql(36)
|
22
|
+
end
|
23
|
+
|
24
|
+
it { t.should be_npn }
|
25
|
+
|
26
|
+
it { t.should_not be_pnp }
|
27
|
+
|
28
|
+
it "should have a name" do
|
29
|
+
t2 = Transistor.new("BC547")
|
30
|
+
t2.name.should eql("BC547")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have pnp" do
|
34
|
+
t2 = Transistor.new(:type => 'pnp')
|
35
|
+
t2.should be_pnp
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should have a pnp alternative initialize" do
|
39
|
+
t2 = Transistor.pnp
|
40
|
+
t2.should be_pnp
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should have a npn alternative initialize" do
|
44
|
+
t2 = Transistor.npn
|
45
|
+
t2.should be_npn
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should have an Ri" do
|
49
|
+
t.ri = 10
|
50
|
+
t.ri.should eql(10)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should have hfe" do
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
describe "Thermal Stuff" do
|
60
|
+
|
61
|
+
it "should calculate thermal resistance" do
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Eletro::Wire" do
|
4
|
+
|
5
|
+
let(:w) { Wire.new }
|
6
|
+
|
7
|
+
describe "Value" do
|
8
|
+
|
9
|
+
it "should have width" do
|
10
|
+
w.width = 5.mm
|
11
|
+
w.width.should eql(5.mm)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should instantiate have i" do
|
15
|
+
w.i = 10.mA
|
16
|
+
w.i.should eql(10.mA)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should calc width" do
|
20
|
+
w.i = 1.A
|
21
|
+
w.size.should be_within(0.001).of(0.8)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Marcos Piccinini
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-28 00:00:00 -02:00
|
18
18
|
default_executable: eletro
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -75,12 +75,15 @@ files:
|
|
75
75
|
- lib/eletro/resistor.rb
|
76
76
|
- lib/eletro/source.rb
|
77
77
|
- lib/eletro/transistor.rb
|
78
|
+
- lib/eletro/wire.rb
|
78
79
|
- spec/colour_test
|
79
80
|
- spec/eletro/capacitor_spec.rb
|
80
81
|
- spec/eletro/ohm_spec.rb
|
81
82
|
- spec/eletro/part_spec.rb
|
82
83
|
- spec/eletro/resistor_spec.rb
|
83
84
|
- spec/eletro/source_spec.rb
|
85
|
+
- spec/eletro/transistor_spec.rb
|
86
|
+
- spec/eletro/wire_spec.rb
|
84
87
|
- spec/eletro_spec.rb
|
85
88
|
- spec/spec_helper.rb
|
86
89
|
has_rdoc: true
|
@@ -121,5 +124,7 @@ test_files:
|
|
121
124
|
- spec/eletro/capacitor_spec.rb
|
122
125
|
- spec/eletro/ohm_spec.rb
|
123
126
|
- spec/eletro/resistor_spec.rb
|
127
|
+
- spec/eletro/transistor_spec.rb
|
124
128
|
- spec/eletro/part_spec.rb
|
129
|
+
- spec/eletro/wire_spec.rb
|
125
130
|
- spec/eletro_spec.rb
|