Class: Infoboxer::MediaWiki::Page

Inherits:
Tree::Document show all
Defined in:
lib/infoboxer/media_wiki/page.rb

Overview

A descendant of Document, representing page, received from Infoboxer::MediaWiki client.

Alongside with document tree structure, knows document's title as represented by MediaWiki and human (non-API) URL.

Instance Attribute Summary collapse

Attributes inherited from Tree::Compound

#children

Attributes inherited from Tree::Node

#params, #parent

Instance Method Summary collapse

Methods included from Navigation::Sections::Container

#intro, #lookup_children, #sections, #subsections

Methods inherited from Tree::Compound

#index_of, #text, #to_tree

Methods inherited from Tree::Node

#==, #children, coder, def_readers, #first?, #index, #inspect, #next_siblings, #prev_siblings, #siblings, #text, #text_, #to_s, #to_tree

Methods included from Navigation::Wikipath

#wikipath

Methods included from Navigation::Sections::Node

#in_sections

Methods included from Navigation::Shortcuts::Node

#bold?, #categories, #external_links, #heading?, #headings, #images, #infobox, #infoboxes, #italic?, #lists, #paragraphs, #tables, #templates, #wikilinks

Methods included from Navigation::Lookup::Node

#_lookup, #_lookup_children, #_lookup_next_siblings, #_lookup_parents, #_lookup_prev_sibling, #_lookup_prev_siblings, #_lookup_siblings, #_matches?, #lookup, #lookup_children, #lookup_next_siblings, #lookup_parents, #lookup_prev_sibling, #lookup_prev_siblings, #lookup_siblings, #matches?, #parent?

Constructor Details

#initialize(client, children, source) ⇒ Page

Returns a new instance of Page.



9
10
11
12
# File 'lib/infoboxer/media_wiki/page.rb', line 9

def initialize(client, children, source)
  @client, @source = client, source
  super(children, title: source['title'], url: source['fullurl'])
end

Instance Attribute Details

#clientMediaWiki (readonly)

Instance of Infoboxer::MediaWiki which this page was received from

Returns:



16
17
18
# File 'lib/infoboxer/media_wiki/page.rb', line 16

def client
  @client
end

#sourceMediaWiktory::Page (readonly)

Instance of MediaWiktory::Page class with source data

Returns:

  • (MediaWiktory::Page)


20
21
22
# File 'lib/infoboxer/media_wiki/page.rb', line 20

def source
  @source
end

#titleString (readonly)

Page title.

Returns:

  • (String)


# File 'lib/infoboxer/media_wiki/page.rb', line 22

#urlString (readonly)

Page friendly URL.

Returns:

  • (String)


30
# File 'lib/infoboxer/media_wiki/page.rb', line 30

def_readers :title, :url

Instance Method Details

#category?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/infoboxer/media_wiki/page.rb', line 41

def category?
  namespace == 'Category'
end

#namespaceObject

FIXME: take from siteinfo!



37
38
39
# File 'lib/infoboxer/media_wiki/page.rb', line 37

def namespace
  Traits::STANDARD_NAMESPACES[source.fetch('ns') + 2] # Media = -2, Specia = -1, Main = 0
end

#traitsObject



32
33
34
# File 'lib/infoboxer/media_wiki/page.rb', line 32

def traits
  client.traits
end