Class: CV::Param
- Inherits:
-
Struct
- Object
- Struct
- CV::Param
- Defined in:
- lib/cv/param.rb,
lib/cv/param.rb
Instance Attribute Summary collapse
-
#accession ⇒ Object
Returns the value of attribute accession.
-
#cv_ref ⇒ Object
Returns the value of attribute cv_ref.
-
#name ⇒ Object
Returns the value of attribute name.
-
#unit ⇒ Object
Returns the value of attribute unit.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(*args) ⇒ Param
constructor
standard struct invocation.
-
#to_xml(xml, name = :cvParam) ⇒ Object
for now, assumes this is a Builder::XmlMarkup object.
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
#accession ⇒ Object
Returns the value of attribute accession
4 5 6 |
# File 'lib/cv/param.rb', line 4 def accession @accession end |
#cv_ref ⇒ Object
Returns the value of attribute cv_ref
4 5 6 |
# File 'lib/cv/param.rb', line 4 def cv_ref @cv_ref end |
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/cv/param.rb', line 4 def name @name end |
#unit ⇒ Object
Returns the value of attribute unit
4 5 6 |
# File 'lib/cv/param.rb', line 4 def unit @unit end |
#value ⇒ Object
Returns the value of attribute 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 |