Class: DataMetaDom::Mappings

Inherits:
Mapping show all
Defined in:
lib/dataMetaDom/record.rb

Overview

A single-value map of a key to a value.

Constant Summary

Constants inherited from Mapping

DataMetaDom::Mapping::BINDING_NONE

Instance Attribute Summary

Attributes inherited from Mapping

#base, #fromT, #name, #toT

Attributes inherited from VerDoccable

#ver

Attributes inherited from Documentable

#docs

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Mapping

#[], #[]=, #initialize, #keys, #parseBase, #values

Methods inherited from VerDoccable

#resetEntity, verConsumed?

Methods inherited from Documentable

#addDoc, #all, #clear, #docConsumed?, #getDoc, #has?, #ids, #initialize

Constructor Details

This class inherits a constructor from DataMetaDom::Mapping

Class Method Details

.consumed?(model, src) ⇒ Boolean

Attempts to consume the instance from the given source, returns it if successful, returns nil otherwise.

  • Parameters

    • model - an instance of a Model

    • src - an instance of SourceFile

Returns:

  • (Boolean)


139
140
141
142
# File 'lib/dataMetaDom/record.rb', line 139

def self.consumed?(model, src)
    src.line =~ /^\s*#{MAPPING}\s+(\w+)\s+.+$/ ? model.addEnum(Mappings.new(DataMetaDom.combineNsBase(
            DataMetaDom.nsAdjustment(src.namespace, model.options, src), $1)).parse(src)) : nil
end

Instance Method Details

#parse(src) ⇒ Object

Parses the current instance from the given source.

  • Parameters

    • src - an instance of SourceFile



154
155
156
157
158
159
160
# File 'lib/dataMetaDom/record.rb', line 154

def parse(src)
    r = src.line.scan(/^\s*\w+\s+\w+\s+(\S+)\s+(\S+)\s*$/)
    raise 'Invalid map specification' unless r && r[0] && r[0][0] && r[0][1]
    self.fromT = DataType.parse(src, r[0][0])
    self.toT = DataType.parse(src, r[0][1])
    parseBase src
end

#sourceKeyWordObject

Returns the keyword for this Mapping implementation, in this case “map



147
# File 'lib/dataMetaDom/record.rb', line 147

def sourceKeyWord; MAPPING end