class CV::Param

Public Class Methods

new(*args) click to toggle source

standard struct invocation. Ensures that value is nil if an empty string is given.

Calls superclass method
# File lib/cv/param.rb, line 10
def initialize(*args)
  args[3] = nil if (args[3] == '')
  super(*args)
end

Public Instance Methods

==(other) click to toggle source
# File lib/cv/param.rb, line 37
def ==(other)
  if !other.nil?
    [:cv_ref, :accession, :name, :value, :unit].inject(true) do |bool, mthd|
      bool && (self.send(mthd) == other.send(mthd))
    end
  else 
    false
  end
end
to_xml(xml, name=:cvParam) click to toggle source

for now, assumes this is a Builder::XmlMarkup object.

returns the xml builder object

# File lib/cv/param.rb, line 17
def to_xml(xml, name=:cvParam)
  hash_to_send = {:cvRef => self.cv_ref, :accession => self.accession, :name => self.name}
  if v=self.value
    hash_to_send[:value] = v
  end
  if unit
    hash_to_send.merge!( 
                        { :unitCvRef => unit.cv_ref, 
                        :unitAccession => unit.accession,
                        :unitName => unit.name } 
                       )
  end

  # xml.send for builder results in tags with 'send' in the front
  xml.tag!(name, hash_to_send)
  # for nokogiri builder
  #xml.send(name, hash_to_send)
  xml
end