Class: CV::Param

Inherits:
Struct
  • Object
show all
Defined in:
lib/cv/param.rb,
lib/cv/param.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Param

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



10
11
12
13
# File 'lib/cv/param.rb', line 10

def initialize(*args)
  args[3] = nil if (args[3] == '')
  super(*args)
end

Instance Attribute Details

#accessionObject

Returns the value of attribute accession

Returns:

  • (Object)

    the current value of accession



4
5
6
# File 'lib/cv/param.rb', line 4

def accession
  @accession
end

#cv_refObject

Returns the value of attribute cv_ref

Returns:

  • (Object)

    the current value of cv_ref



4
5
6
# File 'lib/cv/param.rb', line 4

def cv_ref
  @cv_ref
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/cv/param.rb', line 4

def name
  @name
end

#unitObject

Returns the value of attribute unit

Returns:

  • (Object)

    the current value of unit



4
5
6
# File 'lib/cv/param.rb', line 4

def unit
  @unit
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



4
5
6
# File 'lib/cv/param.rb', line 4

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



37
38
39
40
41
42
43
44
45
# 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) ⇒ Object

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

returns the xml builder object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 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