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

base[RW]

The hash of the “from” (source) values to the “to” (target) values.

fromT[RW]

DataType “from” (source)

name[RW]

Name of this mapping data type including namespace if any.

toT[RW]

DataType “to” (target)

Public Class Methods

new(name) click to toggle source

Creates an instance for the given full data type name, including namespace if any.

Calls superclass method
# File lib/dataMetaDom/record.rb, line 38
def initialize(name)
    #noinspection RubyArgCount
    super()
    @name = name.to_sym; @base = {}
end

Public Instance Methods

[](key) click to toggle source

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
[]=(key, val) click to toggle source

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
keys() click to toggle source

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
parseBase(source) click to toggle source

Parses the mapping, the keys and the values from the given source.

# 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
values() click to toggle source

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