Class: OmfEc::Parameter

Inherits:
Object
  • Object
show all
Defined in:
lib/omf_ec/parameter.rb

Overview

This class describes a Parameter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name, description, defaultValue = nil) ⇒ Parameter

Create a new Parameter instance

  • id = parameter identifier

  • name = name for this parameter

  • description = short description of this parameter

  • defaultValue = optional, a defautl value for this parameter (default=nil)



22
23
24
25
26
27
# File 'lib/omf_ec/parameter.rb', line 22

def initialize(id, name, description, defaultValue = nil)
  @id = id
  @name = name != nil ? name : id
  @description = description
  @defaultValue = defaultValue
end

Instance Attribute Details

#defaultValueObject (readonly)

Returns the value of attribute defaultValue.



12
13
14
# File 'lib/omf_ec/parameter.rb', line 12

def defaultValue
  @defaultValue
end

#descriptionObject (readonly)

Returns the value of attribute description.



12
13
14
# File 'lib/omf_ec/parameter.rb', line 12

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/omf_ec/parameter.rb', line 12

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/omf_ec/parameter.rb', line 12

def name
  @name
end

Instance Method Details

#to_xmlObject

Return the definition of this Parameter as an XML element

Return

an XML element with the definition of this Parameter



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/omf_ec/parameter.rb', line 34

def to_xml
  a = REXML::Element.new("parameter")
  a.add_attribute("id", id)
  a.add_attribute("name", name)
  if (description != nil)
    a.add_element("description").text = description
  end
  if (defaultValue != nil)
    a.add_element("default").text = defaultValue
  end
  return a
end