module OmfEc::CreatePropertiesModule
This module defines the methods used to create new Properties when defining Prototypes/Applications in Experiments
Public Instance Methods
addProperties(properties)
click to toggle source
Add a list of properties described in a hash table where key is the property name and the value its value. If value starts with “$”, value is interpreted as the name of another property to bind to.
-
properties = a
Hash
describing a set of properties
# File lib/omf_ec/property.rb, line 141 def addProperties(properties) if properties != nil if properties.kind_of?(Hash) properties.each {|k, v| if v.kind_of?(Symbol) v = v.to_s end if v.kind_of?(String) && v[0] == ?$ # is binding bindProperty(k, v[1..-1]) else setProperty(k, v) end } elsif properties.kind_of? Array properties.each {|p| if ! p.kind_of? OmfEc::Property raise "Propertie array needs to contain Property, but is '" \ + p.class.to_s + "'." end @properties += [p] } else raise "Properties declarations needs to be a Hash or Array, but is '" \ + properties.class.to_s + "'." end end end
bindProperty(propName, propRef = propName)
click to toggle source
Bind the value of a property to another property in the context
-
propName = name of application property
-
propRef =
Property
to bind to (default = ‘propName’)
# File lib/omf_ec/property.rb, line 128 def bindProperty(propName, propRef = propName) prop = OmfEc::Property.new(propName, propRef, nil, true) @properties += [prop] end
setProperty(propName, value, unit = nil)
click to toggle source
Set a property of the application to a specific value
-
propName = Name of the application property
-
value = Value of property
-
unit = optional, unit for this
Property
# File lib/omf_ec/property.rb, line 117 def setProperty(propName, value, unit = nil) prop = OmfEc::Property.new(propName, value, unit) @properties += [prop] end