Class: DataMetaDom::BitSet

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

Overview

A Bit Set mapping, one instance holding a set of references to the values packed tightly as a bit set.

Constant Summary

Constants inherited from Mapping

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)


104
105
106
107
# File 'lib/dataMetaDom/record.rb', line 104

def self.consumed?(model, src)
    src.line =~ /^\s*#{BITSET}\s+(\w+)\s+.+$/ ? model.addEnum(BitSet.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



119
120
121
122
123
124
125
# File 'lib/dataMetaDom/record.rb', line 119

def parse(src)
    r = src.line.scan(/^\s*\w+\s+\w+\s+(\S+)\s*$/)
    raise 'Invalid bitset specification' unless r && r[0] && r[0][0]
    self.fromT = INT4 #platform type is up to the concrete generator
    self.toT = DataType.parse(src, r[0][0])
    parseBase src
end

#sourceKeyWordObject

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



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

def sourceKeyWord; BITSET end