From db2a0457a8a472e4770c409ca1299b03e41fc5dd Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Tue, 17 May 2022 11:30:37 -0700 Subject: Initial generic part library --- library.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 library.rb (limited to 'library.rb') diff --git a/library.rb b/library.rb new file mode 100644 index 0000000..1fb682b --- /dev/null +++ b/library.rb @@ -0,0 +1,23 @@ +require "./lace" + +$smd = "0805" + +def r(ohms, footprint=$smd) + ohms = ohms.to_s + ohms.sub!(/(ohms?|Ω)$/i, "") + comp("R", footprint, "resistor", "#{Lace.number(ohms)}Ω") +end + +def c(farads, footprint=$smd) + farads = farads.to_s + farads.sub!(/f(arads?)?$/i, "") + comp("C", footprint, "capacitor", "#{Lace.number(farads)}F") +end + +def d(spec, footprint=$smd) + comp("D", footprint, "diode", spec) +end + +def led(spec, ohms, footprint=$smd) + comp("D", footprint, "LED", spec) - self.r(ohms, footprint) +end -- cgit v1.2.3