Class: Html2rss::AutoSource::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/auto_source/channel.rb

Overview

Extracts channel information from

  1. the HTML document’s <head>.

  2. the HTTP response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parsed_body, url:, headers:, articles: [], stylesheets: []) ⇒ Channel

Returns a new instance of Channel.

Parameters:

  • parsed_body (Nokogiri::HTML::Document)

    The parsed HTML document.

  • url (Addressable::URI)

    The URL of the channel.

  • headers (Hash<String, String>)

    the http headers

  • articles (Array<Html2rss::AutoSource::Article>) (defaults to: [])

    The articles.



16
17
18
19
20
21
22
# File 'lib/html2rss/auto_source/channel.rb', line 16

def initialize(parsed_body, url:, headers:, articles: [], stylesheets: [])
  @parsed_body = parsed_body
  @url = url
  @headers = headers
  @articles = articles
  @stylesheets = stylesheets
end

Instance Attribute Details

#articles=(value) ⇒ Object (writeonly)

Sets the attribute articles

Parameters:

  • value

    the value to set the attribute articles to.



24
25
26
# File 'lib/html2rss/auto_source/channel.rb', line 24

def articles=(value)
  @articles = value
end

#stylesheetsObject (readonly)

Returns the value of attribute stylesheets.



25
26
27
# File 'lib/html2rss/auto_source/channel.rb', line 25

def stylesheets
  @stylesheets
end

Instance Method Details

#descriptionObject



30
# File 'lib/html2rss/auto_source/channel.rb', line 30

def description = extract_description

#generatorObject



35
36
37
# File 'lib/html2rss/auto_source/channel.rb', line 35

def generator
  "html2rss V. #{::Html2rss::VERSION} (using auto_source scrapers: #{scraper_counts})"
end

#imageObject



31
# File 'lib/html2rss/auto_source/channel.rb', line 31

def image = extract_image

#languageObject



29
# File 'lib/html2rss/auto_source/channel.rb', line 29

def language = extract_language

#last_build_dateObject



33
# File 'lib/html2rss/auto_source/channel.rb', line 33

def last_build_date = headers['last-modified']

#titleObject



28
# File 'lib/html2rss/auto_source/channel.rb', line 28

def title = extract_title

#ttlObject



32
# File 'lib/html2rss/auto_source/channel.rb', line 32

def ttl = extract_ttl

#urlObject



27
# File 'lib/html2rss/auto_source/channel.rb', line 27

def url = extract_url