Class: HTMLPage
- Inherits:
-
Object
- Object
- HTMLPage
- Includes:
- HTML2Markdown::Converter
- Defined in:
- lib/html2markdown/html_page.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(options, &content_extrator) ⇒ HTMLPage
constructor
A new instance of HTMLPage.
- #markdown ⇒ Object
- #markdown! ⇒ Object
Methods included from HTML2Markdown::Converter
#debug, #method_missing, #parse_element, #to_markdown, #wrap_node
Constructor Details
#initialize(options, &content_extrator) ⇒ HTMLPage
Returns a new instance of HTMLPage.
8 9 10 11 12 13 14 15 16 |
# File 'lib/html2markdown/html_page.rb', line 8 def initialize(,&content_extrator) @host = [:host] @url = [:url] if (@contents = [:contents]) == nil doc = Nokogiri::HTML(open(@url)) @contents = doc.at_css('body').send(:inner_html) || doc.inner_html end @content_extrator = content_extrator end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class HTML2Markdown::Converter
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
6 7 8 |
# File 'lib/html2markdown/html_page.rb', line 6 def contents @contents end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/html2markdown/html_page.rb', line 6 def url @url end |
Instance Method Details
#markdown ⇒ Object
18 19 20 |
# File 'lib/html2markdown/html_page.rb', line 18 def markdown @markdown ||= markdown! end |
#markdown! ⇒ Object
22 23 24 |
# File 'lib/html2markdown/html_page.rb', line 22 def markdown! @markdown = to_markdown(contents) end |