Class: Wikiscript::Page

Inherits:
Object
  • Object
show all
Includes:
LogUtils::Logging
Defined in:
lib/wikiscript/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, text: nil) ⇒ Page



11
12
13
14
15
16
17
18
# File 'lib/wikiscript/page.rb', line 11

def initialize( title, text: nil )
  ## todo: check title
  ## replace title spaces w/ _ ????
  ##  to allow "pretty" titles - why? why not??

  @title = title
  @text  = text
end

Instance Attribute Details

#titleObject (readonly)

Returns the value of attribute title.



9
10
11
# File 'lib/wikiscript/page.rb', line 9

def title
  @title
end

Instance Method Details

#download_textObject



24
25
26
# File 'lib/wikiscript/page.rb', line 24

def download_text
  Client.new.text( @title )
end

#parseObject

todo/change: use/find a different name e.g. doc/elements/etc. - why? why not?



28
29
30
# File 'lib/wikiscript/page.rb', line 28

def parse   ## todo/change: use/find a different name e.g. doc/elements/etc. - why? why not?
  PageReader.parse( text )
end

#textObject



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

def text
  @text ||= download_text   # cache text (from request)
end