Class: Eletro::Transistor
Instance Attribute Summary collapse
-
#hfe ⇒ Object
Returns the value of attribute hfe.
-
#i ⇒ Object
Returns the value of attribute i.
-
#name ⇒ Object
Returns the value of attribute name.
-
#ri ⇒ Object
Returns the value of attribute ri.
Attributes inherited from Part
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Transistor
constructor
A new instance of Transistor.
- #npn? ⇒ Boolean
- #pnp? ⇒ Boolean
- #w ⇒ Object
Methods inherited from Part
#*, #+, #-, #/, #abs, #coerce, #method_missing, #round, #to_f, #to_i, #to_s
Constructor Details
#initialize(*args) ⇒ Transistor
Returns a new instance of Transistor.
8 9 10 11 12 |
# File 'lib/eletro/transistor.rb', line 8 def initialize *args params, txt = *args.partition { |a| a.is_a?(Hash) } @npn = params[0] && params[0][:type] == "pnp" ? false : true @name = txt.join end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Eletro::Part
Instance Attribute Details
#hfe ⇒ Object
Returns the value of attribute hfe.
6 7 8 |
# File 'lib/eletro/transistor.rb', line 6 def hfe @hfe end |
#i ⇒ Object
Returns the value of attribute i.
6 7 8 |
# File 'lib/eletro/transistor.rb', line 6 def i @i end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/eletro/transistor.rb', line 6 def name @name end |
#ri ⇒ Object
Returns the value of attribute ri.
6 7 8 |
# File 'lib/eletro/transistor.rb', line 6 def ri @ri end |
Class Method Details
.npn ⇒ Object
31 32 33 |
# File 'lib/eletro/transistor.rb', line 31 def self.npn new end |
.pnp ⇒ Object
27 28 29 |
# File 'lib/eletro/transistor.rb', line 27 def self.pnp new(:type => "pnp") end |
Instance Method Details
#npn? ⇒ Boolean
18 19 20 |
# File 'lib/eletro/transistor.rb', line 18 def npn? @npn end |
#pnp? ⇒ Boolean
22 23 24 |
# File 'lib/eletro/transistor.rb', line 22 def pnp? !@npn end |
#w ⇒ Object
14 15 16 |
# File 'lib/eletro/transistor.rb', line 14 def w v * i end |