Class Extractor

BaseClass for an extractor strategy.

This class follows the pattern with inheritance from Lua classes.

Metamethods

Extractor:__index (key) Lookup of missing class members.

Methods

Extractor:create (...) Create a new instance.
Extractor:_init (...) Initialize a new instance.
Extractor:setType (str) Set type
Extractor:hasType () Has type
Extractor:getType () Get the type of the strategy.
Extractor:addPattern (str, initial, final) Add pattern Register a single pattern.
Extractor:addKeyword (str) Add keyword Transform a single keyword to a registered set of patterns.
Extractor:addDelimiters (first, second[, exclude=false]) Add delimiters Transform a pair of delimiters to a registered set of patterns.
Extractor:numPatterns () Num patterns
Extractor:find (str, pos) Try to find the string for this strategy.
Extractor:onCast (func) Set the on-cast method.
Extractor:cast (str) Cast the string into the correct type for this strategy.
Extractor:placeholder () Get the placeholder for this strategy.


Metamethods

Extractor:__index (key)
Lookup of missing class members.

Parameters:

Returns:

any

Raises:

on wrong arguments

Methods

Extractor:create (...)
Create a new instance.

Parameters:

Returns:

self
Extractor:_init (...)
Initialize a new instance.

Parameters:

  • ... vararg list of patterns

Returns:

self
Extractor:setType (str)
Set type

Parameters:

  • str string to be used as type

Returns:

self
Extractor:hasType ()
Has type

Returns:

boolean
Extractor:getType ()
Get the type of the strategy. All extractor strategies have an explicit type name.

Returns:

string
Extractor:addPattern (str, initial, final)
Add pattern Register a single pattern.

Parameters:

  • str string to be used for pattern
  • initial number offset
  • final number offset

Returns:

self
Extractor:addKeyword (str)
Add keyword Transform a single keyword to a registered set of patterns.

Parameters:

  • str string to be used for keywords

Returns:

self
Extractor:addDelimiters (first, second[, exclude=false])
Add delimiters Transform a pair of delimiters to a registered set of patterns.

Parameters:

  • first string delimiter
  • second string delimiter
  • exclude nil or boolean delimiters (default false)

Returns:

self
Extractor:numPatterns ()
Num patterns

Returns:

number
Extractor:find (str, pos)
Try to find the string for this strategy. The goodness of the match is given by the returned position. If found it should return a position and the found string.

Parameters:

  • str string used as the extraction source
  • pos number for an inclusive index where extraction starts

Returns:

nil or number,number

Raises:

on wrong arguments
Extractor:onCast (func)
Set the on-cast method.

Parameters:

  • func function

Returns:

self
Extractor:cast (str)
Cast the string into the correct type for this strategy.

Parameters:

  • str string used as the extraction source (unused)

Returns:

any

Raises:

Unconditional error unless handler exist
Extractor:placeholder ()
Get the placeholder for this strategy.

Returns:

string
generated by LDoc 1.4.6