Method: Eletro::Resistor#parse

Defined in:
lib/eletro/resistor.rb

#parse(txt) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/eletro/resistor.rb', line 15

def parse txt
  if m = txt.match(/#{mult.keys.join('|')}/)
    txt.gsub!(/#{m[0]}/, ".")
    m = mult[m[0]]
  end
  num = txt.to_f
  num *= m if m
  num
end