Module: MediaWiktory::Wikipedia::Modules::Extracts

Defined in:
lib/mediawiktory/wikipedia/modules/extracts.rb

Overview

Returns plain-text or limited HTML extracts of the given pages.

The "submodule" (MediaWiki API term) is included in action after setting some param, providing additional tweaking for this param. Example (for Actions::Query and its submodules):

api.query             # returns Actions::Query
   .prop(:revisions)  # adds prop=revisions to action URL, and includes Modules::Revisions into action
   .limit(10)         # method of Modules::Revisions, adds rvlimit=10 to URL

All submodule's parameters are documented as its public methods, see below.

Instance Method Summary collapse

Instance Method Details

#chars(value) ⇒ self

How many characters to return. Actual text returned might be slightly longer.

Parameters:

  • value (Integer)

Returns:

  • (self)


25
26
27
# File 'lib/mediawiktory/wikipedia/modules/extracts.rb', line 25

def chars(value)
  merge(exchars: value.to_s)
end

#continue(value) ⇒ self

When more results are available, use this to continue.

Parameters:

  • value (Integer)

Returns:

  • (self)


76
77
78
# File 'lib/mediawiktory/wikipedia/modules/extracts.rb', line 76

def continue(value)
  merge(excontinue: value.to_s)
end

#introself

Return only content before the first section.

Returns:

  • (self)


48
49
50
# File 'lib/mediawiktory/wikipedia/modules/extracts.rb', line 48

def intro()
  merge(exintro: 'true')
end

#limit(value) ⇒ self

How many extracts to return. (Multiple extracts can only be returned if exintro is set to true.)

Parameters:

  • value (Integer, "max")

Returns:

  • (self)


41
42
43
# File 'lib/mediawiktory/wikipedia/modules/extracts.rb', line 41

def limit(value)
  merge(exlimit: value.to_s)
end

#plaintextself

Return extracts as plain text instead of limited HTML.

Returns:

  • (self)


55
56
57
# File 'lib/mediawiktory/wikipedia/modules/extracts.rb', line 55

def plaintext()
  merge(explaintext: 'true')
end

#sectionformat(value) ⇒ self

How to format sections in plaintext mode:

Parameters:

  • value (String)

    One of "plain" (No formatting), "wiki" (Wikitext-style formatting (== like this ==)), "raw" (This module's internal representation (section titles prefixed with

    )).

Returns:

  • (self)


63
64
65
# File 'lib/mediawiktory/wikipedia/modules/extracts.rb', line 63

def sectionformat(value)
  _sectionformat(value) or fail ArgumentError, "Unknown value for sectionformat: #{value}"
end

#sentences(value) ⇒ self

How many sentences to return.

Parameters:

  • value (Integer)

Returns:

  • (self)


33
34
35
# File 'lib/mediawiktory/wikipedia/modules/extracts.rb', line 33

def sentences(value)
  merge(exsentences: value.to_s)
end