Class: Wikiscript::Page
- Inherits:
-
Object
- Object
- Wikiscript::Page
- Includes:
- LogUtils::Logging
- Defined in:
- lib/wikiscript/page.rb
Instance Attribute Summary collapse
-
#lang ⇒ Object
readonly
Returns the value of attribute lang.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
-
.get(title, lang: Wikiscript.lang) ⇒ Object
todo/check: add a fetch/download alias - why? why not?.
Instance Method Summary collapse
- #download_text ⇒ Object
-
#initialize(text = nil, title: nil, lang: Wikiscript.lang) ⇒ Page
constructor
A new instance of Page.
-
#parse ⇒ Object
todo/change: use/find a different name e.g.
- #text ⇒ Object
Constructor Details
#initialize(text = nil, title: nil, lang: Wikiscript.lang) ⇒ Page
19 20 21 22 23 24 25 26 27 |
# File 'lib/wikiscript/page.rb', line 19 def initialize( text=nil, title: nil, lang: Wikiscript.lang ) ## todo: check title ## replace title spaces w/ _ ???? ## to allow "pretty" titles - why? why not?? @text = text @title = title @lang = lang end |
Instance Attribute Details
#lang ⇒ Object (readonly)
Returns the value of attribute lang.
9 10 11 |
# File 'lib/wikiscript/page.rb', line 9 def lang @lang end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
9 10 11 |
# File 'lib/wikiscript/page.rb', line 9 def title @title end |
Class Method Details
.get(title, lang: Wikiscript.lang) ⇒ Object
todo/check: add a fetch/download alias - why? why not?
12 13 14 15 16 |
# File 'lib/wikiscript/page.rb', line 12 def self.get( title, lang: Wikiscript.lang ) ## todo/check: add a fetch/download alias - why? why not? o = new( title: title, lang: lang ) ## o.text ## "force" download / fetch o end |
Instance Method Details
#download_text ⇒ Object
33 34 35 |
# File 'lib/wikiscript/page.rb', line 33 def download_text Client.new.text( @title, lang: @lang ) end |
#parse ⇒ Object
todo/change: use/find a different name e.g. doc/elements/etc. - why? why not?
37 38 39 |
# File 'lib/wikiscript/page.rb', line 37 def parse ## todo/change: use/find a different name e.g. doc/elements/etc. - why? why not? PageReader.parse( text ) end |
#text ⇒ Object
29 30 31 |
# File 'lib/wikiscript/page.rb', line 29 def text @text ||= download_text # cache text (from request) end |