Class: Oddb2xml::SwissmedicInfoExtractor
- Defined in:
- lib/oddb2xml/extractor.rb
Instance Attribute Summary
Attributes inherited from Extractor
Instance Method Summary collapse
Methods inherited from Extractor
Constructor Details
This class inherits a constructor from Oddb2xml::Extractor
Instance Method Details
#to_hash ⇒ Object
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
# File 'lib/oddb2xml/extractor.rb', line 344 def to_hash data = Hash.new{|h,k| h[k] = [] } return data unless @xml.size > 0 result = MedicalInformationsContent.parse(@xml.sub(Strip_For_Sax_Machine, ''), :lazy => true) result.medicalInformation.each do |pac| lang = pac.lang.to_s next unless lang =~ /de|fr/ item = {} item[:refdata] = true, item[:name] = (name = pac.title) ? name : '' item[:owner] = (ownr = pac.authHolder) ? ownr : '' item[:style] = Nokogiri::HTML.fragment(pac.style).to_html(:encoding => 'UTF-8') html = Nokogiri::HTML.fragment(pac.content.force_encoding('UTF-8')) item[:paragraph] = html numbers = /(\d{5})[,\s]*(\d{5})?|(\d{5})[,\s]*(\d{5})?[,\s]*(\d{5})?/.match(html) if numbers [$1, $2, $3].compact.each do |n| # plural item[:monid] = n data[lang] << item end end end data end |