Module:Rfx/doc
![]() | This is a documentation subpage for Module:Rfx. It may contain usage information, categories and other content that is not part of the original module page. |
This is a library for getting information about individual requests for adminship (RfA) and requests for bureaucratship (RfB) pages on the English Wikipedia. It is not meant to be used directly from wiki pages, but rather to be used by other Lua modules.
Creating new objects
First of all, the library must be loaded, like this:
local rfx = require( 'Module:Rfx' )
Once the library is loaded, you can make a new rfx object like this:
local myRfx = rfx.new( pagename )
The pagename
variable should be the name of a valid RfA or RfB page, for example:
local exampleRfa = rfx.new( 'Wikipedia:Requests for adminship/Example' )
If pagename
is not specified, or the page is not a subpage of Wikipedia:Requests for adminship or Wikipedia:Requests for bureaucratship, then rfx.new
will return nil
.
Methods and properties
Once you have created a new rfx
object, there are a number of methods and properties that you can use. They are all read-only.
- Properties
type
: the type of the rfx. This is either "rfa
" or "rfb
".page
: the title object for the RfX page. See the reference manual for details on how to use title objects.supports
: the number of supports in the RfX.nil
if the supports could not be processed.opposes
: the number of opposes in the RfX.nil
if the opposes could not be processed.neutrals
: the number of neutrals in the RfX.nil
if the neutrals could not be processed.percent
: the support percentage. Calculated by and rounded to the nearest integer.nil
if it could not be processed.endTime
: the end time of the RfX. This is a string value taken from the RfX page.nil
if it could not be found.user
: the username of the RfX candidate.nil
if it could not be found.
- Methods
Methods must be called with the colon syntax:
local supportUsers = exampleRfa:getSupportUsers()
getSupportUsers()
: gets an array containing the usernames that supported the RfX. If any usernames could not be processed, the text "Error processing vote no. n" is inserted instead, a long with a random number to prevent the error text being confused as a duplicate vote.getOpposeUsers()
: gets an array containing the usernames that opposed the RfX. Functions similarly togetSupportUsers()
.getNeutralUsers()
: gets an array containing the usernames that were neutral at the RfX. Functions similarly togetSupportUsers()
.dupesExist()
: returns a boolean indicating whether there were any duplicate votes at the RfX. Returnsnil
if the vote tables couldn't be processed.getSecondsLeft()
: returns the number of seconds left before the RfX is due to close. Once it is due to close, shows zero. If the ending time cannot be found, returnsnil
.getTimeLeft()
: returns a string showing the time left before the RfX is due to close. The string is in the format "x days, y hours
".
You can compare rfx
objects with the ==
operator. This will return true only if the two objects point to the same page. tostring( rfx )
will return prefixedTitle
from the RfX page's title object (see the reference manual).