diff options
| -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 | ||
