Class: MyExperimentREST::MyExperimentIOData

Inherits:
Object
  • Object
show all
Defined in:
lib/myexperiment-rest/workflow.rb

Overview

Contains all available information about an input or output: name, descriptions and examples. The last two are lists. – Currently both inputs and outputs contain the same information. If that changes we can subclass this one.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ MyExperimentIOData

Returns a new instance of MyExperimentIOData.



107
108
109
110
111
# File 'lib/myexperiment-rest/workflow.rb', line 107

def initialize(attributes)
  @name = attributes[:name]
  @descriptions = attributes[:descriptions]
  @examples = attributes[:examples]
end

Instance Attribute Details

#descriptionsObject (readonly)

Returns the value of attribute descriptions.



105
106
107
# File 'lib/myexperiment-rest/workflow.rb', line 105

def descriptions
  @descriptions
end

#examplesObject (readonly)

Returns the value of attribute examples.



105
106
107
# File 'lib/myexperiment-rest/workflow.rb', line 105

def examples
  @examples
end

#nameObject (readonly)

Returns the value of attribute name.



105
106
107
# File 'lib/myexperiment-rest/workflow.rb', line 105

def name
  @name
end

Class Method Details

.from_xml(xml_node) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/myexperiment-rest/workflow.rb', line 113

def self.from_xml(xml_node)
  name = ''
  descriptions = []
  examples = []

  xml_node.each_element do |n|
    if n.name.eql? "name"
      name = n.children[0].to_s
    elsif n.name.eql? "descriptions"
      n.each_element do |d|
        descriptions << d.children[0].to_s
      end if n.children?
    elsif n.name.eql? "examples"
      n.each_element do |e|
        examples << e.children[0].to_s
      end if n.children?
    end
  end


  new(
    :name => name,
    :descriptions => descriptions,
    :examples => examples)

end