Class: Mspire::UserParam
- Inherits:
-
Struct
- Object
- Struct
- Mspire::UserParam
- Defined in:
- lib/mspire/user_param.rb,
lib/mspire/user_param.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#unit ⇒ Object
Returns the value of attribute unit.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#accession ⇒ Object
returns nil.
-
#initialize(*args) ⇒ UserParam
constructor
takes a few different incantations:.
- #to_xml(xml) ⇒ Object
Constructor Details
#initialize(*args) ⇒ UserParam
takes a few different incantations:
name, unit_acc# or CV::Param object
name, value, unit_acc# or CV::Param object
name, value, type, unit_acc# or CV::Param object
19 20 21 22 23 24 25 26 |
# File 'lib/mspire/user_param.rb', line 19 def initialize(*args) self.unit = if args.size > 1 && ((args.last.is_a?(::CV::Param) || args.last =~ /^[A-Za-z]+:\d+$/)) unit_arg = args.pop unit_arg.is_a?(::CV::Param) ? unit_arg : Mspire::CV::Param[unit_arg] end self.name, self.value, self.type = args end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/mspire/user_param.rb', line 4 def name @name end |
#type ⇒ Object
Returns the value of attribute type
4 5 6 |
# File 'lib/mspire/user_param.rb', line 4 def type @type end |
#unit ⇒ Object
Returns the value of attribute unit
4 5 6 |
# File 'lib/mspire/user_param.rb', line 4 def unit @unit end |
#value ⇒ Object
Returns the value of attribute value
4 5 6 |
# File 'lib/mspire/user_param.rb', line 4 def value @value end |
Instance Method Details
#accession ⇒ Object
returns nil
9 10 11 12 |
# File 'lib/mspire/user_param.rb', line 9 def accession # that way all params can be queried by accession and not raise error nil end |
#to_xml(xml) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mspire/user_param.rb', line 28 def to_xml(xml) atts = { name: name, value: value, type: type } if unit atts.merge!( { :unitCvRef => unit.cv_ref, :unitAccession => unit.accession, :unitName => unit.name } ) end xml.userParam(atts) xml end |