Class: HTMLPage

Inherits:
Object
  • Object
show all
Includes:
HTML2Markdown::Converter
Defined in:
lib/html2markdown/html_page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options,&content_extrator)
  @host = options[:host]
  @url = options[:url]
  if (@contents = options[: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

#contentsObject

Returns the value of attribute contents.



6
7
8
# File 'lib/html2markdown/html_page.rb', line 6

def contents
  @contents
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/html2markdown/html_page.rb', line 6

def url
  @url
end

Instance Method Details

#markdownObject



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