diff options
| author | Julian Blake Kongslie | 2022-05-17 11:30:37 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2022-05-17 11:30:37 -0700 |
| commit | db2a0457a8a472e4770c409ca1299b03e41fc5dd (patch) | |
| tree | 568700063297e0b4332e7b2a483f306a2340f115 /library.rb | |
| parent | Automatically finding E-series matches and metric prefixes (diff) | |
| download | lace-db2a0457a8a472e4770c409ca1299b03e41fc5dd.tar.xz | |
Initial generic part library
Diffstat (limited to '')
| -rw-r--r-- | library.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/library.rb b/library.rb new file mode 100644 index 0000000..1fb682b --- /dev/null +++ b/library.rb | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | require "./lace" | ||
| 2 | |||
| 3 | $smd = "0805" | ||
| 4 | |||
| 5 | def r(ohms, footprint=$smd) | ||
| 6 | ohms = ohms.to_s | ||
| 7 | ohms.sub!(/(ohms?|Ω)$/i, "") | ||
| 8 | comp("R", footprint, "resistor", "#{Lace.number(ohms)}Ω") | ||
| 9 | end | ||
| 10 | |||
| 11 | def c(farads, footprint=$smd) | ||
| 12 | farads = farads.to_s | ||
| 13 | farads.sub!(/f(arads?)?$/i, "") | ||
| 14 | comp("C", footprint, "capacitor", "#{Lace.number(farads)}F") | ||
| 15 | end | ||
| 16 | |||
| 17 | def d(spec, footprint=$smd) | ||
| 18 | comp("D", footprint, "diode", spec) | ||
| 19 | end | ||
| 20 | |||
| 21 | def led(spec, ohms, footprint=$smd) | ||
| 22 | comp("D", footprint, "LED", spec) - self.r(ohms, footprint) | ||
| 23 | end | ||
