Class: Wiki::Api::Page
- Inherits:
-
Object
- Object
- Wiki::Api::Page
- Defined in:
- lib/wiki/api/page.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#parsed_page ⇒ Object
Returns the value of attribute parsed_page.
Class Method Summary collapse
Instance Method Summary collapse
- #headline(headline_name) ⇒ Object
- #headlines ⇒ Object
-
#initialize(options = {}) ⇒ Page
constructor
A new instance of Page.
- #reset! ⇒ Object
- #to_html ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Page
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/wiki/api/page.rb', line 8 def initialize(={}) self.name = [:name] if .include? :name @@config ||= nil if @@config.nil? # use the connection to collect HTML pages for parsing @connect = Wiki::Api::Connect.new else # using a local HTML file for parsing end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/wiki/api/page.rb', line 6 def name @name end |
#parsed_page ⇒ Object
Returns the value of attribute parsed_page.
6 7 8 |
# File 'lib/wiki/api/page.rb', line 6 def parsed_page @parsed_page end |
Class Method Details
.config=(config = {}) ⇒ Object
57 58 59 |
# File 'lib/wiki/api/page.rb', line 57 def config=(config = {}) @@config = config end |
Instance Method Details
#headline(headline_name) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/wiki/api/page.rb', line 32 def headline headline_name headlines = [] self.parse_blocks(headline_name).each do |headline_name, elements| headline = PageHeadline.new name: headline_name elements.each do |element| # nokogiri element headline.block << element end headlines << headline end headlines end |
#headlines ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/wiki/api/page.rb', line 19 def headlines headlines = [] self.parse_blocks.each do |headline_name, elements| headline = PageHeadline.new name: headline_name elements.each do |element| # nokogiri element headline.block << element end headlines << headline end headlines end |
#reset! ⇒ Object
52 53 54 |
# File 'lib/wiki/api/page.rb', line 52 def reset! self.parse_page = nil end |
#to_html ⇒ Object
47 48 49 50 |
# File 'lib/wiki/api/page.rb', line 47 def to_html self.load_page! self.parsed_page.to_xhtml indent: 3, indent_text: " " end |