Class: DataMetaDom::Mappings
- Inherits:
-
Mapping
- Object
- Documentable
- VerDoccable
- Mapping
- DataMetaDom::Mappings
- 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
Attributes inherited from VerDoccable
Attributes inherited from Documentable
Class Method Summary collapse
-
.consumed?(model, src) ⇒ Boolean
Attempts to consume the instance from the given source, returns it if successful, returns nil otherwise.
Instance Method Summary collapse
-
#parse(src) ⇒ Object
Parses the current instance from the given source.
-
#sourceKeyWord ⇒ Object
Returns the keyword for this Mapping implementation, in this case “
map
”.
Methods inherited from Mapping
#[], #[]=, #initialize, #keys, #parseBase, #values
Methods inherited from VerDoccable
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
-
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., 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 |
#sourceKeyWord ⇒ Object
Returns the keyword for this Mapping implementation, in this case “map
”
147 |
# File 'lib/dataMetaDom/record.rb', line 147 def sourceKeyWord; MAPPING end |