class DataMetaDom::RecAttrSet

The record attribute with the unordered set of arguments. See the RecAttrList for the ordered list implementation.

Attributes

argSet[R]

Unordered unique set of the arguments

Public Class Methods

new(keyword) click to toggle source

Creates an instance with the given keyword

Calls superclass method DataMetaDom::RecAttr::new
# File lib/dataMetaDom/recAttr.rb, line 135
def initialize(keyword); super(keyword); @argSet = Set.new end

Public Instance Methods

addArg(val) click to toggle source

Adds the given argument to the instance

Calls superclass method DataMetaDom::RecAttr#addArg
# File lib/dataMetaDom/recAttr.rb, line 150
def addArg(val)
    k = val.to_sym
    raise "Duplicate arg #{k} in the set of #{argSetTextual}" if @argSet.member?(k)
    @argSet << k
    #RecAttr.instance_method(:addArg).bind(self).call k - fortunately, overkill in this case, can do with just:
    super k
end
argSetTextual() click to toggle source

Builds textual for the set of the arguments, for diagnostics.

# File lib/dataMetaDom/recAttr.rb, line 144
def argSetTextual; @argSet.map { |a| a.to_s }.sort.join(':') end
getKey() click to toggle source

Builds the unique key for the set of arguments on the instance

# File lib/dataMetaDom/recAttr.rb, line 147
def getKey; argSetTextual.to_sym end
hasArg?(arg) click to toggle source

Determines if the instance has the given argument

# File lib/dataMetaDom/recAttr.rb, line 141
def hasArg?(arg); argSet.member?(arg) end
parse(src) click to toggle source

Parses the instance from the given source.

# File lib/dataMetaDom/recAttr.rb, line 163
def parse(src)
    recAttrParse(src)
    # look if there are any duplicates, if there are it's an error:
    counterHash = Hash.new(0)
    args.each { |a| k=a.to_sym; counterHash[k] += 1 }
    dupes = []; counterHash.each { |k, v| dupes << k if v > 1 }
    raise "Duplicate arguments for #{self} - [#{dupes.join(',')}]" unless dupes.empty?
    @argSet = Set.new(args)
    updateKey
    self
end
Also aliased as: recAttrParse
recAttrParse(src)

Engages the super's parse method via the alias

Alias for: parse