Class: Infoboxer::Tree::Wikilink
- Includes:
- Linkable
- Defined in:
- lib/infoboxer/tree/wikilink.rb
Overview
Internal MediaWiki link class.
See Wikipedia docs for extensive explanation of Wikilink concept.
Note, that Wikilink is Linkable, so you can #follow it to obtain linked pages.
Instance Attribute Summary collapse
-
#anchor ⇒ Object
readonly
Anchor part of hyperlink, like
History
for[Argentina#History]
. -
#interwiki ⇒ Object
readonly
Interwiki identifier.
-
#name ⇒ Object
readonly
"Clean" wikilink name, for ex.,
Cities
for[Category:Cities]
. -
#namespace ⇒ Object
readonly
Wikilink namespace,
Category
for[Category:Cities]
, empty string (notnil
!) for just[Cities]
. -
#refinement ⇒ Object
readonly
Refinement part of link name.
-
#topic ⇒ Object
readonly
Topic part of link name.
Attributes inherited from Link
Attributes inherited from Compound
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(link, label = nil, namespace: nil, interwiki: nil) ⇒ Wikilink
constructor
A new instance of Wikilink.
Methods included from Linkable
Methods inherited from Compound
Methods inherited from Node
#==, #children, coder, def_readers, #first?, #index, #inspect, #next_siblings, #prev_siblings, #siblings, #text, #text_, #to_s, #to_tree
Methods included from Navigation::Wikipath
Methods included from Navigation::Sections::Node
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(link, label = nil, namespace: nil, interwiki: nil) ⇒ Wikilink
Returns a new instance of Wikilink.
15 16 17 18 19 20 |
# File 'lib/infoboxer/tree/wikilink.rb', line 15 def initialize(link, label = nil, namespace: nil, interwiki: nil) super(link, label, namespace: namespace, interwiki: interwiki) @namespace = namespace || '' @interwiki = interwiki parse_name! end |
Instance Attribute Details
#anchor ⇒ Object (readonly)
Anchor part of hyperlink, like History
for [Argentina#History]
37 38 39 |
# File 'lib/infoboxer/tree/wikilink.rb', line 37 def anchor @anchor end |
#interwiki ⇒ Object (readonly)
Interwiki identifier. For example, [[wikt:Argentina]]
will have "Argentina"
as its #name and "wikt"
(wiktionary) as an
interwiki. TODO: how to use it.
See Wikipedia docs for details.
30 31 32 |
# File 'lib/infoboxer/tree/wikilink.rb', line 30 def interwiki @interwiki end |
#name ⇒ Object (readonly)
"Clean" wikilink name, for ex., Cities
for [Category:Cities]
23 24 25 |
# File 'lib/infoboxer/tree/wikilink.rb', line 23 def name @name end |
#namespace ⇒ Object (readonly)
Wikilink namespace, Category
for [Category:Cities]
, empty
string (not nil
!) for just [Cities]
34 35 36 |
# File 'lib/infoboxer/tree/wikilink.rb', line 34 def namespace @namespace end |
#refinement ⇒ Object (readonly)
Refinement part of link name.
See #topic for explanation.
52 53 54 |
# File 'lib/infoboxer/tree/wikilink.rb', line 52 def refinement @refinement end |
#topic ⇒ Object (readonly)
Topic part of link name.
There's so-called "Pipe trick"
in wikilink markup, which defines that [Phoenix, Arizona]
link
has main part ("Phoenix") and refinement part ("Arizona"). So,
we are splitting it here in topic
and #refinement.
The same way, [Pipe (programming)]
has topic == 'Pipe'
and
refinement == 'programming'
47 48 49 |
# File 'lib/infoboxer/tree/wikilink.rb', line 47 def topic @topic end |