class Definition
Base class for definitions (target, configuration, or project).
Definitions
def initialize(context, package, name)
Initialize a new definition.
Signature
-
parameter
contextContext The project context.
-
parameter
packagePackage The package.
-
parameter
nameString The definition name.
Implementation
def initialize(context, package, name)
@context = context
@package = package
@name = name
@description = nil
end
def freeze
Make the definition immutable after it has been loaded from a teapot file.
Implementation
def freeze
@name.freeze
@description.freeze
super
end
def inspect
Signature
-
returns
String The string representation.
Implementation
def inspect
"\#<#{self.class.name} #{@name}>"
end
attr :context
The context in which the definition was loaded:
attr :package
The package in which the definition was specified:
attr :name
The name of the definition:
attr :description
A textual description of the definition, possibly in markdown format:
def description=(text)
Assign a description with automatic removal of common leading indentation.
Signature
-
parameter
textString The description text.
Implementation
def description=(text)
if text =~ /^(\t+)/
text = text.gsub(/#{$1}/, "")
end
@description = text
end
def path
The path that the definition is relative to:
Implementation
def path
@package.path
end
def to_s
Signature
-
returns
String The string representation.
Implementation
def to_s
"#<#{self.class} #{@name.dump}>"
end