class DataMetaDom::Mapping
A mapping - of values from one data type to values of another data types. Supports only DataMeta DOM standard types
For command line details either check the new method's source or the README.rdoc file, the usage section.
Constants
- BINDING_NONE
Empty binding for evaluation to avoid exposing class variables
Attributes
The hash of the “from” (source) values to the “to” (target) values.
DataType
“from” (source)
Name of this mapping data type including namespace if any.
DataType
“to” (target)
Public Class Methods
Creates an instance for the given full data type name, including namespace if any.
# File lib/dataMetaDom/record.rb, line 38 def initialize(name) #noinspection RubyArgCount super() @name = name.to_sym; @base = {} end
Public Instance Methods
Returns the value for the given key as mapped.
-
Parameters:
-
key
- the value of the type “from” (source) to get the matching value of the type “to” (target) for.
-
# File lib/dataMetaDom/record.rb, line 49 def [](key); @base[key] end
Assign the mapped value for the given key, useful for building a mapping from the code.
-
Parameters:
-
key
- the value of the type “from” (source) -
val
- the matching value of the type “to” (target).
-
# File lib/dataMetaDom/record.rb, line 57 def []=(key, val); base[key] = val end
All the keys of the type “from” (source) defined on the mapping, sorted
# File lib/dataMetaDom/record.rb, line 67 def keys; @base.keys.sort end
Parses the mapping, the keys and the values from the given source.
-
Parameters
-
source
- an instance ofSourceFile
-
# File lib/dataMetaDom/record.rb, line 74 def parseBase(source) hashSource = '{' while (line = source.nextLine) case line when /^\s*#{END_KW}\s*$/ self.ver = source.ver unless self.ver self.docs = source.docs.clone source.docs.clear raise "Version missing for the Mapping #{name}" unless self.ver break else hashSource << line end # case end # while line @base = eval(hashSource + '}', BINDING_NONE) self end
All the values of the type “to” (target) defined on the mapping, sorted
# File lib/dataMetaDom/record.rb, line 62 def values; @base.values.sort end