<commit_before>require 'rss'

module RSSCache
  # An RSS or Atom feed.
  class Feed
    # Returns the Feed content; one of RSS::Rss or RSS::Atom.
    attr_reader :feed

    # Returns the RSSCache::Fetcher for the Feed.
    attr_reader :fetcher

    # Returns or sets the URL for the Feed.
    attr_accessor :url

    ##
    # Creates a new instance of Feed.

    def initialize(args = {})
      @url     ||= args[:url]
      @fetcher ||= RSSCache::Fetcher.new url: url
      update
    end

    ##
    # Returns the Feed's items/entries in the for of an array of
    # RSSCache::Feed::Item.

    def items
      feed.items.map do |i|
        RSSCache::Feed::Item.new item: i, type: feed.feed_type
      end
    end

    ##
    # Returns the Feed's link.

    def link
      feed.feed_type == 'rss' ? feed.channel.link : feed.link.href
    end

    ##
    # Returns the Feed's title.

    def title
      feed.feed_type == 'rss' ? feed.channel.title : feed.title.content
    end

    ##
    # Updates the Feed.

    def update
      @fetcher.fetch
      @feed = RSS::Parser.parse @fetcher.content
      unless @feed && %w{rss atom}.include?(@feed.feed_type)
        fail FormatError, 'Unsupported feed format'
      end<commit_msg>Change ambiguous `feed` attr to `content`<commit_after>require 'rss'

module RSSCache
  # An RSS or Atom feed.
  class Feed
    # Returns the Feed content; one of RSS::Rss or RSS::Atom.
    attr_reader :content

    # Returns the RSSCache::Fetcher for the Feed.
    attr_reader :fetcher

    # Returns or sets the URL for the Feed.
    attr_accessor :url

    ##
    # Creates a new instance of Feed.

    def initialize(args = {})
      @url     ||= args[:url]
      @fetcher ||= RSSCache::Fetcher.new url: url
      update
    end

    ##
    # Returns the Feed's items/entries in the for of an array of
    # RSSCache::Feed::Item.

    def items
      content.items.map do |i|
        RSSCache::Feed::Item.new item: i, type: content.feed_type
      end
    end

    ##
    # Returns the Feed's link.

    def link
      content.feed_type == 'rss' ? content.channel.link : content.link.href
    end

    ##
    # Returns the Feed's title.

    def title
      return content.channel.title if content.feed_type == 'rss'
      content.title.content
    end

    ##
    # Updates the Feed.

    def update
      @fetcher.fetch
      @content = RSS::Parser.parse @fetcher.content
      unless @content && %w{rss atom}.include?(@content.feed_type)
        fail FormatError, 'Unsupported feed format'
      end
{'fraction_non_alphanumeric': 0.10410094637223975, 'fraction_numerical': 0.0, 'mean_word_length': 2.2525641025641026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1637986', 'n_tokens_mistral': 847, 'n_tokens_neox': 789, 'n_words': 248}