Class: RubyCrawl::SiteCrawler::PageResult

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycrawl/site_crawler.rb

Overview

Page result yielded to the block with lazy markdown.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, html:, links:, metadata:, depth:) ⇒ PageResult

Returns a new instance of PageResult.



12
13
14
15
16
17
18
# File 'lib/rubycrawl/site_crawler.rb', line 12

def initialize(url:, html:, links:, metadata:, depth:)
  @url = url
  @html = html
  @links = links
   = 
  @depth = depth
end

Instance Attribute Details

#depthObject (readonly)

Returns the value of attribute depth.



10
11
12
# File 'lib/rubycrawl/site_crawler.rb', line 10

def depth
  @depth
end

#htmlObject (readonly)

Returns the value of attribute html.



10
11
12
# File 'lib/rubycrawl/site_crawler.rb', line 10

def html
  @html
end

Returns the value of attribute links.



10
11
12
# File 'lib/rubycrawl/site_crawler.rb', line 10

def links
  @links
end

#metadataObject (readonly)

Returns the value of attribute metadata.



10
11
12
# File 'lib/rubycrawl/site_crawler.rb', line 10

def 
  
end

#urlObject (readonly)

Returns the value of attribute url.



10
11
12
# File 'lib/rubycrawl/site_crawler.rb', line 10

def url
  @url
end

Instance Method Details

#final_urlObject

The final URL after redirects.



26
27
28
# File 'lib/rubycrawl/site_crawler.rb', line 26

def final_url
  ['final_url'] || [:final_url] || url
end

#markdownObject

Lazy markdown conversion with resolved URLs.



21
22
23
# File 'lib/rubycrawl/site_crawler.rb', line 21

def markdown
  @markdown ||= MarkdownConverter.convert(html, base_url: final_url)
end