Class Mediawiki::Text
In: mediawiki/core.rb
Parent: Object

the pure plain text

Methods

each_link   inspect   length   new   node_id   obliterate   rawtext   size   text  

Constants

DeletedText = '<deleted>'

Attributes

flags  [R]  text flags: this could be
gzip:the text is compressed
utf8:the text is encoded in utf8 (but maybe the opposite depending on mediawiki software setup)
object:we do not have text but a serialized PHP object (I hope we will never ever see this)
internal_links  [R]  Array of all internal links found in the Text as strings
tid  [R]  the text id

Public Class methods

creates a new Text. wiki is the Wiki the revision belongs to, all other parameters correspond to the fields in the corresponding database table.

[Source]

# File mediawiki/core.rb, line 1149
    def initialize(wiki, tid, text, flags, keeptext=true)
      @wiki = wiki
      @tid = tid
      @text = text
      @flags = flags

      @internal_links = []

      parse_text

      @text = DeletedText unless keeptext
    end

Public Instance methods

iterator over all links found in the text given as strings. For a link iterator giving Page objects please see the corresponding Revision object (as Text objects do not have timestamps we need to decide whether a link is dangling)

[Source]

# File mediawiki/core.rb, line 1180
    def each_link(&block)
      @internal_links.each(&block)
    end

[Source]

# File mediawiki/core.rb, line 1184
    def inspect
      "#<Mediawiki::Text id=#{@tid}>"
    end
length()

Alias for size

id string for dotfile creation

[Source]

# File mediawiki/core.rb, line 1189
    def node_id
      "t#{tid}"
    end

Text obliteration.

Sets the following instance_variables to obliterated values unless the corresponding keeps are set to true:

text :unless :text => true
links :unless :links => true

[Source]

# File mediawiki/core.rb, line 1207
    def obliterate(keeps={})
      @text = ''      unless keeps[:text]
      @internal_links.collect! { |l| 'link' } unless keeps[:links]
    end

the raw text as found in the database

[Source]

# File mediawiki/core.rb, line 1163
    def rawtext
      @text
    end

the size of the text in bytes (this is similar but not equal to the size of the text in chars due to UTF-8 encoding).

[Source]

# File mediawiki/core.rb, line 1195
    def size
      @text.size
    end

the text converted according to the flags given.

currently this is the same as rawtext, we will change this if needed

[Source]

# File mediawiki/core.rb, line 1170
    def text
      # here we should do some conversions according to @flags
      # but it seems this is not needed for our data
      @text
    end

[Validate]