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.
-
#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
#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 |
# File 'lib/wikiwhat/page.rb', line 25 def initialize(title, ={}) @title = title run() end |
Instance Attribute Details
#head ⇒ Object (readonly)
Returns the value of attribute head.
7 8 9 |
# File 'lib/wikiwhat/page.rb', line 7 def head @head end |
#header(header) ⇒ Object (readonly)
Returns the value of attribute header.
7 8 9 |
# File 'lib/wikiwhat/page.rb', line 7 def header @header end |
#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 |
#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 |
#paragraphs(value = 1) ⇒ Object (readonly)
Memoized methods for each operation.
Returns instance variable or runs method.
57 58 59 |
# File 'lib/wikiwhat/page.rb', line 57 def paragraphs @paragraphs end |
#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 |
#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 |
#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
#run(hash) ⇒ Object
Iterates over the options hash.
hash - options hash
Runs the appropriate method based on the options hash.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/wikiwhat/page.rb', line 35 def run(hash) hash.each do |key, value| case key when:img_list image_list when:header header(value) when:refs find_ref_list when:sidebar_img when:num_paragraphs paragraphs(value) when:sidebar end end end |
#sidebar_image ⇒ Object
73 74 75 |
# File 'lib/wikiwhat/page.rb', line 73 def @sidebar_image ||= end |