class DataMetaDom::Documentable
Anything that can have documentation.
Attributes
docs[RW]
The hash keyed by the target.
Public Class Methods
new()
click to toggle source
Initializes the instance with an empty hash.
# File lib/dataMetaDom/docs.rb, line 82 def initialize; @docs = {} end
Public Instance Methods
addDoc(doc)
click to toggle source
Adds the document by putting it into the underlying cache with the target key.
# File lib/dataMetaDom/docs.rb, line 88 def addDoc(doc) @docs[doc.target] = doc end
all()
click to toggle source
All the instances of the Doc stored on this instance.
# File lib/dataMetaDom/docs.rb, line 96 def all; @docs.values end
clear()
click to toggle source
Reinitializes the instance with no docs.
# File lib/dataMetaDom/docs.rb, line 108 def clear; @docs[] = {} end
docConsumed?(source)
click to toggle source
Attempts to consume a Doc from the given source, returns true if succeeded.
-
Parameters:
-
source- an instance ofSourceFile -
target- the target, the format of theDoc.
-
# File lib/dataMetaDom/docs.rb, line 116 def docConsumed?(source) source.line =~ /^\s*#{DOC}\s+(\w+)$/ ? addDoc(Doc.parse(source, [$1])) : nil end
getDoc(key)
click to toggle source
Fetches the instance of Doc by the given key, the target
# File lib/dataMetaDom/docs.rb, line 85 def getDoc(key); @docs[key] end
has?(key)
click to toggle source
Determines if the given document target is defined on this instance.
-
Parameter:
-
key- the target.
-
# File lib/dataMetaDom/docs.rb, line 103 def has?(key) ; @docs.member?(key) end
ids()
click to toggle source
All the ids, namely the targets of all the documents on this instance.
# File lib/dataMetaDom/docs.rb, line 93 def ids; @docs.keys end