Open main menu

Yugipedia β

Changes

Module:InfoWrapper

1,202 bytes added, 5 years ago
Add __class attribute. Add setTitle method. Add --Doc documentation.
-- <pre>
-- [=[Doc@module Info class@description Creates objects an object to store module info.-- @author [[User:Becasita]]-- @contact [[User talk:Becasita]]]=]
-- Define [[Doc@class:InfoClass@description Stores and provides an interface to manage module info.@exportable]]
local InfoClass = {};
InfoClass.__index = InfoClass;
InfoClass.__class = InfoClass;
-- [[Doc@function InfoClass new@description Initialize the Initializes an instance of `InfoClass`.@return {InfoClass} New instance of the `InfoClass`.]]
function InfoClass.new( title )
local data = {
end
-- [[Doc@method InfoClass setTitle@description Returns its gathered Changes the instance title.@parameter {string|nil} title The new title. If `nil`, the empty string is used.@return {StringBuffer} `self`]]function InfoClass:setTitle( title ) self._title = title or '';  return self;end --[[Doc@method InfoClass getCategories@description Get the stored categories.@return {table} Table, as an array, of all of the stored categories.]]
function InfoClass:getCategories()
return self._categories;
end
-- [[Doc@method InfoClass getErrors@description Returns its gathered Get the stored errors.@return {table} Table, as an array, of all of the stored errors.]]
function InfoClass:getErrors()
return self._errors;
end
-- [[Doc@method InfoClass category@description Store associated Stores a new category.@parameter {string} category The category name(no need to prefix the `Category` namespace).@return {InfoClass} `self`]]
function InfoClass:category( category )
table.insert( self._categories, category );
 
return self;
end
-- [[Doc@method InfoClass error@description Store Stores a new error.@parameter {string} message The error message.@parameter {*} default A default return a value.@return {*|InfoClass} `default` or `self`.]]
function InfoClass:error( message, default )
self._errors.exists = true;
end
--[[Doc
@method InfoClass dumpCategories
]]
function InfoClass:dumpCategories( callback )
callback = callback or function( cat, index )
return cat;
end;
 
local categories = {
self._errors.exists and ('[[Category:((%s)) transclusions to be checked]]'):format( self._title );
};
 
for index, cat in ipairs( self._categories ) do
table.insert(
);
end
 
return table.concat( categories );
end
--[[Doc
@method InfoClass dumpErrors
]]
function InfoClass:dumpErrors( callback )
callback = callback or function( err, index )
return ('%d - %s'):format( index, err );
end;
 
local errors = {};
 
for index, err in ipairs( self._errors ) do
table.insert( errors, callback( err, index ) );
end
  return table.concat( errors, '\n' );-- TODO: more flexible delimiter
end
-- [=[Doc@export Instatiation methodexports The `InfoClass` class constructor (`new`).@see [[#InfoClass.new]]]=]
return {
['new'] = InfoClass.new,
}
-- </pre>
Bureaucrats, System administrator, Administrators
57,479
edits