Class: Html2rss::Selectors::ItemScope

Inherits:
Data
  • Object
show all
Defined in:
lib/html2rss/selectors/item_scope.rb

Overview

Per-item extraction scope: owns the article node and page base_url for one extraction pass. Channel hashes are injected (and cached) by Html2rss::Selectors.

Distinct from Context, which is the post-processor invocation bag (+options+). Post-processor config is derived from #channel — not a parallel bag.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url

Returns:

  • (Object)

    the current value of base_url



11
12
13
# File 'lib/html2rss/selectors/item_scope.rb', line 11

def base_url
  @base_url
end

#channelObject (readonly)

Returns the value of attribute channel

Returns:

  • (Object)

    the current value of channel



11
12
13
# File 'lib/html2rss/selectors/item_scope.rb', line 11

def channel
  @channel
end

#itemObject (readonly)

Returns the value of attribute item

Returns:

  • (Object)

    the current value of item



11
12
13
# File 'lib/html2rss/selectors/item_scope.rb', line 11

def item
  @item
end

#scraperObject (readonly)

Returns the value of attribute scraper

Returns:

  • (Object)

    the current value of scraper



11
12
13
# File 'lib/html2rss/selectors/item_scope.rb', line 11

def scraper
  @scraper
end

Instance Method Details

#context_for(options:) ⇒ Context

Builds a post-processor Context carrying this scope for nested selects.

Parameters:

  • options (Hash)

    post-processor options from the selector config

Options Hash (options:):

  • :name (String)

    post-processor name

Returns:



25
26
27
# File 'lib/html2rss/selectors/item_scope.rb', line 25

def context_for(options:)
  Context.new(options:, item:, config: { channel: }, scraper:, item_scope: self)
end

#select(name) ⇒ Object+

Selects an attribute using this scope's item and base_url.

Parameters:

  • name (Symbol, String)

Returns:

  • (Object, Array<Object>)


17
# File 'lib/html2rss/selectors/item_scope.rb', line 17

def select(name) = scraper.select_in_scope(name, self)