Class: Article

Inherits:
Struct
  • Object
show all
Defined in:
lib/wp/wiki.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ Article

Returns a new instance of Article.



30
31
32
33
34
35
36
37
38
39
# File 'lib/wp/wiki.rb', line 30

def initialize(page)
  self.xml = page
  self.title = page.at("title").text

  if redirect = page.at("redirect")
    self.redirect = redirect["title"]
  else
    self.text = page.at("text").text
  end
end

Instance Attribute Details

#redirectObject

Returns the value of attribute redirect

Returns:

  • (Object)

    the current value of redirect



28
29
30
# File 'lib/wp/wiki.rb', line 28

def redirect
  @redirect
end

#redirected_fromObject

Returns the value of attribute redirected_from

Returns:

  • (Object)

    the current value of redirected_from



28
29
30
# File 'lib/wp/wiki.rb', line 28

def redirected_from
  @redirected_from
end

#textObject

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



28
29
30
# File 'lib/wp/wiki.rb', line 28

def text
  @text
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



28
29
30
# File 'lib/wp/wiki.rb', line 28

def title
  @title
end

#xmlObject

Returns the value of attribute xml

Returns:

  • (Object)

    the current value of xml



28
29
30
# File 'lib/wp/wiki.rb', line 28

def xml
  @xml
end

Instance Method Details

#redirect?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/wp/wiki.rb', line 42

def redirect?
  !!redirect
end

#to_htmlObject Also known as: html



47
48
49
50
# File 'lib/wp/wiki.rb', line 47

def to_html
  # WikiCloth::Parser.new(data: text).to_html
  WikiParser.new(data: text).to_html
end