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.
-
#uri ⇒ Object
Returns the value of attribute uri.
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
Returns a new instance of Page.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/wiki/api/page.rb', line 8 def initialize(={}) self.name = [:name] if .include? :name uri = [:uri] if .include? :uri @@config ||= nil if @@config.nil? || !uri.nil? # use the connection to collect HTML pages for parsing @connect = Wiki::Api::Connect.new uri: uri 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 |
#uri ⇒ Object
Returns the value of attribute uri.
6 7 8 |
# File 'lib/wiki/api/page.rb', line 6 def uri @uri end |
Class Method Details
.config=(config = {}) ⇒ Object
59 60 61 |
# File 'lib/wiki/api/page.rb', line 59 def config=(config = {}) @@config = config end |
Instance Method Details
#headline(headline_name) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/wiki/api/page.rb', line 34 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
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/wiki/api/page.rb', line 21 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
54 55 56 |
# File 'lib/wiki/api/page.rb', line 54 def reset! self.parse_page = nil end |
#to_html ⇒ Object
49 50 51 52 |
# File 'lib/wiki/api/page.rb', line 49 def to_html self.load_page! self.parsed_page.to_xhtml indent: 3, indent_text: " " end |