Class: Oddb2xml::Builder
- Inherits:
-
Object
- Object
- Oddb2xml::Builder
- Defined in:
- lib/oddb2xml/builder.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#companies ⇒ Object
Returns the value of attribute companies.
-
#ean14 ⇒ Object
Returns the value of attribute ean14.
-
#flags ⇒ Object
Returns the value of attribute flags.
-
#infos ⇒ Object
Returns the value of attribute infos.
-
#infos_zur_rose ⇒ Object
Returns the value of attribute infos_zur_rose.
-
#items ⇒ Object
Returns the value of attribute items.
-
#lppvs ⇒ Object
Returns the value of attribute lppvs.
-
#migel ⇒ Object
Returns the value of attribute migel.
-
#orphan ⇒ Object
Returns the value of attribute orphan.
-
#packs ⇒ Object
Returns the value of attribute packs.
-
#people ⇒ Object
Returns the value of attribute people.
-
#refdata ⇒ Object
Returns the value of attribute refdata.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#tag_suffix ⇒ Object
Returns the value of attribute tag_suffix.
-
#xsd ⇒ Object
Returns the value of attribute xsd.
Instance Method Summary collapse
- #check_name(obj, lang = :de) ⇒ Object
- #emit_substance(xml, substance, emit_active = false) ⇒ Object
-
#initialize(args = {}) ⇒ Builder
constructor
A new instance of Builder.
- #to_dat(subject = nil) ⇒ Object
- #to_xml(subject = nil) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Builder
Returns a new instance of Builder.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/oddb2xml/builder.rb', line 44 def initialize(args = {}) @options = args @subject = nil @refdata = {} @items = {} # Items from Preparations.xml in BAG, using GTINs as key @flags = {} @lppvs = {} @infos = {} @packs = {} @migel = {} @infos_zur_rose = {} # zurrose @actions = [] @orphan = [] @ean14 = false @companies = [] @people = [] @tag_suffix = nil @pharmacode = {} # index pharmacode => item if block_given? yield self end end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def actions @actions end |
#companies ⇒ Object
Returns the value of attribute companies.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def companies @companies end |
#ean14 ⇒ Object
Returns the value of attribute ean14.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def ean14 @ean14 end |
#flags ⇒ Object
Returns the value of attribute flags.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def flags @flags end |
#infos ⇒ Object
Returns the value of attribute infos.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def infos @infos end |
#infos_zur_rose ⇒ Object
Returns the value of attribute infos_zur_rose.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def infos_zur_rose @infos_zur_rose end |
#items ⇒ Object
Returns the value of attribute items.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def items @items end |
#lppvs ⇒ Object
Returns the value of attribute lppvs.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def lppvs @lppvs end |
#migel ⇒ Object
Returns the value of attribute migel.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def migel @migel end |
#orphan ⇒ Object
Returns the value of attribute orphan.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def orphan @orphan end |
#packs ⇒ Object
Returns the value of attribute packs.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def packs @packs end |
#people ⇒ Object
Returns the value of attribute people.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def people @people end |
#refdata ⇒ Object
Returns the value of attribute refdata.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def refdata @refdata end |
#subject ⇒ Object
Returns the value of attribute subject.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def subject @subject end |
#tag_suffix ⇒ Object
Returns the value of attribute tag_suffix.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def tag_suffix @tag_suffix end |
#xsd ⇒ Object
Returns the value of attribute xsd.
38 39 40 |
# File 'lib/oddb2xml/builder.rb', line 38 def xsd @xsd end |
Instance Method Details
#check_name(obj, lang = :de) ⇒ Object
457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/oddb2xml/builder.rb', line 457 def check_name(obj, lang = :de) ean = obj[:ean].to_i refdata = @refdata[ean] if lang == :de name = (refdata && refdata[:desc_de]) ? refdata[:desc_de] : obj[:sequence_name] elsif lang == :fr name = (refdata && refdata[:desc_fr]) ? refdata[:desc_fr] : obj[:sequence_name] else return false end return false if !name || name.empty? || name.length < 3 name end |
#emit_substance(xml, substance, emit_active = false) ⇒ Object
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
# File 'lib/oddb2xml/builder.rb', line 640 def emit_substance(xml, substance, emit_active=false) xml.MORE_INFO substance.more_info if substance.more_info xml.SUBSTANCE_NAME substance.name xml.IS_ACTIVE_AGENT substance.is_active_agent if emit_active if substance.dose if substance.qty.is_a?(Float) or substance.qty.is_a?(Fixnum) xml.QTY substance.qty xml.UNIT substance.unit else xml.DOSE_TEXT substance.dose.to_s end end if substance.chemical_substance xml.CHEMICAL_SUBSTANCE { emit_substance(xml, substance.chemical_substance) } end if substance.salts and substance.salts.size > 0 xml.SALTS { substance.salts.each { |salt| xml.SALT { emit_substance(xml, salt) } } } end end |
#to_dat(subject = nil) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/oddb2xml/builder.rb', line 74 def to_dat(subject=nil) Oddb2xml.log "to_dat subject #{subject ? subject.to_s : @subject.to_s} for #{self.class}" if subject self.send('build_' + subject.to_s) elsif @subject self.send('build_' + @subject.to_s) end end |