Sha256: 1adf7b98820db987370c8bd6af6ba512655721a6e7ac0328750ce08849938240

Contents?: true

Size: 985 Bytes

Versions: 3

Compression:

Stored size: 985 Bytes

Contents

module CV
  class Param
    attr_accessor :cv_ref, :accession, :name, :value
    # A valueless CV::Param object that describes the units being used
    attr_accessor :unit

    def initialize(cv_ref, accession, name, value=nil)
      (@cv_ref, @accession, @name, @value) = [cv_ref, accession, name, value]
    end

    def to_xml(xml, name=:cvParam)
      hash_to_send = {:cvRef => @cvref, :accession => @accession, :name => @name}
      hash_to_send[:value] = @value if @value
      if unit
        hash_to_send.merge!( { :unitCvRef => unit.cv_ref, 
                            :unitAccession => unit.accession,
                            :unitName => unit.name } )
      end
      xml.send(name, hash_to_send)
    end

    def ==(other)
      if !other.nil? && other.is_a?(CV::Param)
        [:cv_ref, :accession, :name, :value, :unit].inject(true) do |bool, mthd|
          bool && (self.send(mthd) == other.send(mthd))
        end
      else ; false
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mspire-0.6.6 lib/cv/param.rb
mspire-0.6.2 lib/cv/param.rb
mspire-0.6.1 lib/cv/param.rb