Class: Wikiwhat::Page
- Inherits:
-
Object
- Object
- Wikiwhat::Page
- Defined in:
- lib/wikiwhat/page.rb
Instance Attribute Summary collapse
-
#head ⇒ Object
readonly
Returns the value of attribute head.
-
#header(header) ⇒ Object
readonly
Returns the value of attribute header.
-
#image_list ⇒ Object
readonly
Returns the value of attribute image_list.
-
#img_list ⇒ Object
readonly
Returns the value of attribute img_list.
-
#paragraphs(value = 1) ⇒ Object
readonly
Memoized methods for each operation.
-
#ref_list ⇒ Object
readonly
Returns the value of attribute ref_list.
-
#sidebar_img_url ⇒ Object
readonly
Returns the value of attribute sidebar_img_url.
-
#sidebar_thumbnail(options = {}) ⇒ Object
readonly
Returns the value of attribute sidebar_thumbnail.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title, options = {}) ⇒ Page
constructor
Set title of article and type of information requested.
-
#run(hash) ⇒ Object
Iterates over the options hash.
- #sidebar_image ⇒ Object
Constructor Details
permalink #initialize(title, options = {}) ⇒ Page
Set title of article and type of information requested.
title - the title of the requested article as a String img_list - True if desired output is a list of all images on the page. header - the desired section header as a String. refs - True if desired output is a list of all references on the
page.
sidebar_img - True if desired output is the image in the sidebar paragraphs - the number of paragraphs from the article as an Interger
TODO sidebar - True if desired output is the contents of the sidebar.
Takes options hash and sets instance variables, then calls appropriate method.
25 26 27 28 29 |
# File 'lib/wikiwhat/page.rb', line 25 def initialize(title, ={}) @title = title run() end |
Instance Attribute Details
permalink #head ⇒ Object (readonly)
Returns the value of attribute head.
7 8 9 |
# File 'lib/wikiwhat/page.rb', line 7 def head @head end |
permalink #header(header) ⇒ Object (readonly)
Returns the value of attribute header.
7 8 9 |
# File 'lib/wikiwhat/page.rb', line 7 def header @header end |
permalink #image_list ⇒ Object (readonly)
Returns the value of attribute image_list.
7 8 9 |
# File 'lib/wikiwhat/page.rb', line 7 def image_list @image_list end |
permalink #img_list ⇒ Object (readonly)
Returns the value of attribute img_list.
7 8 9 |
# File 'lib/wikiwhat/page.rb', line 7 def img_list @img_list end |
permalink #paragraphs(value = 1) ⇒ Object (readonly)
Memoized methods for each operation.
Returns instance variable or runs method.
60 61 62 |
# File 'lib/wikiwhat/page.rb', line 60 def paragraphs @paragraphs end |
permalink #ref_list ⇒ Object (readonly)
Returns the value of attribute ref_list.
7 8 9 |
# File 'lib/wikiwhat/page.rb', line 7 def ref_list @ref_list end |
permalink #sidebar_img_url ⇒ Object (readonly)
Returns the value of attribute sidebar_img_url.
7 8 9 |
# File 'lib/wikiwhat/page.rb', line 7 def @sidebar_img_url end |
permalink #sidebar_thumbnail(options = {}) ⇒ Object (readonly)
Returns the value of attribute sidebar_thumbnail.
7 8 9 |
# File 'lib/wikiwhat/page.rb', line 7 def @sidebar_thumbnail end |
permalink #title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/wikiwhat/page.rb', line 7 def title @title end |
Instance Method Details
permalink #run(hash) ⇒ Object
Iterates over the options hash.
hash - options hash
Runs the appropriate method based on the options hash.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/wikiwhat/page.rb', line 36 def run(hash) hash.each do |key, value| case key when:img_list image_list when:header header(value) when:refs ref_list when:sidebar_img when:num_paragraphs paragraphs(value) when:sidebar when:sidebar_thumb (:width => value[:width], :height => value[:height]) end end end |
permalink #sidebar_image ⇒ Object
[View source]
76 77 78 |
# File 'lib/wikiwhat/page.rb', line 76 def @sidebar_image ||= end |