Class: Oddb2xml::Extractor

Inherits:
Object
  • Object
show all
Defined in:
lib/oddb2xml/extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Extractor

Returns a new instance of Extractor.



24
25
26
# File 'lib/oddb2xml/extractor.rb', line 24

def initialize(xml)
  @xml = xml
end

Instance Attribute Details

#xmlObject

Returns the value of attribute xml.



23
24
25
# File 'lib/oddb2xml/extractor.rb', line 23

def xml
  @xml
end

Instance Method Details

#correct_code(pharmacode, length = 7) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/oddb2xml/extractor.rb', line 27

def correct_code(pharmacode, length=7)
  if pharmacode.length != length # restore zero at the beginnig
    ("%0#{length}i" % pharmacode.to_i)
  else
    pharmacode
  end
end