summaryrefslogtreecommitdiff
path: root/library.rb
blob: 1fb682b289d982476f7f9d843a74d07c4a75bbdc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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