blob: c10d535480f7c5c53e344a52bcd8ce98e6b783ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
=begin
* Name: opentox.rb
* Description: Architecture shims
* Author: Andreas Maunz <andreas@maunz.de>
* Date: 10/2012
=end
# This avoids having to prefix everything with "RDF::" (e.g. "RDF::DC").
# So that we can use our old code mostly as is.
include RDF
module OpenTox
# Help function to provide the metadata= functionality.
# Downward compatible to opentox-ruby.
# @param [Hash] Key-Value pairs with the metadata
# @return self
def metadata=(hsh)
hsh.each {|k,v|
self[k]=v
}
end
### Index Structures
# Create parameter positions map
# @return [Hash] A hash with keys parameter names and values parameter positions
def build_parameter_positions
unless @parameter_positions
@parameters = parameters
@parameter_positions = @parameters.each_index.inject({}) { |h,idx|
h[@parameters[idx][DC.title.to_s]] = idx
h
}
end
end
### Associative Search Operations
# Search a model for a given parameter
# @param[String] The parameter title
# @return[Object] The parameter value
def find_parameter_value(title)
build_parameter_positions
res = @parameters[@parameter_positions[title]][OT.paramValue.to_s] if @parameter_positions[title]
res
end
end
|