Module: MediaWiktory::Wikipedia::Modules::Coordinates

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

Overview

Returns coordinates 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

#continue(value) ⇒ self

When more results are available, use this to continue.

Parameters:

  • value (String)

Returns:

  • (self)


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

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

#distancefrompage(value) ⇒ self

Return distance in meters from the geographical coordinates of every valid result from the coordinates of this page.

Parameters:

  • value (String)

Returns:

  • (self)


75
76
77
# File 'lib/mediawiktory/wikipedia/modules/coordinates.rb', line 75

def distancefrompage(value)
  merge(codistancefrompage: value.to_s)
end

#distancefrompoint(value) ⇒ self

Return distance in meters from the geographical coordinates of every valid result from the given coordinates.

Parameters:

  • value (String)

Returns:

  • (self)


67
68
69
# File 'lib/mediawiktory/wikipedia/modules/coordinates.rb', line 67

def distancefrompoint(value)
  merge(codistancefrompoint: value.to_s)
end

#limit(value) ⇒ self

How many coordinates to return.

Parameters:

  • value (Integer, "max")

Returns:

  • (self)


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

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

#primary(value) ⇒ self

Whether to return only primary coordinates ("primary"), secondary ("secondary") or both ("all").

Parameters:

  • value (String)

    One of "primary", "secondary", "all".

Returns:

  • (self)


54
55
56
# File 'lib/mediawiktory/wikipedia/modules/coordinates.rb', line 54

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

#prop(*values) ⇒ self

Which additional coordinate properties to return.

Parameters:

  • values (Array<String>)

    Allowed values: "type", "name", "dim", "country", "region", "globe".

Returns:

  • (self)


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

def prop(*values)
  values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" }
end