Class: Etna::Cwl::SourceLoader

Inherits:
Loader
  • Object
show all
Defined in:
lib/etna/cwl.rb

Instance Method Summary collapse

Methods inherited from Loader

#as_array, #as_mapped_array, #map, #optional, #or

Instance Method Details

#load(val) ⇒ Object

Resolves a string of the forms “a-primary-identifier” or “step_name/output” into

[:primary_inputs, "a-primary-identifier"] or
["step_name", "output"] respectively


121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/etna/cwl.rb', line 121

def load(val)
  parts = []

  if val.is_a?(Symbol)
    val = val.to_s
  end

  if val.is_a?(Array)
    parts = PrimitiveLoader::STRING.as_array.load(val)
  elsif val.is_a?(String)
    parts = val.split('/', max = 2)
  end

  if parts.length == 1
    return [:primary_inputs, parts[0]]
  elsif parts.length == 2
    return parts
  end

  raise "Unexpected value for source #{val.inspect}"
end