class Genit::RssFeedItemTitle
Retrieve the title element of an item element of an RSS feed from a news article.
Attributes
title[R]
Public: Get the first title content from a news article.
We first search for <h1> header level, then <h2>, etc to <h6>. If the news article doesn’t contains any <h*> element, the title() method returns the ISO date string (yyyy-mm-dd) found in the news article pathname.
Returns the String
title of the news article.
Public Class Methods
new(news_pathname)
click to toggle source
# File lib/genit/project/rss_feed.rb, line 81 def initialize news_pathname @news_pathname = news_pathname @title = NewsUtils.get_date_from_filename @news_pathname doc = HtmlDocument.open_fragment(@news_pathname) ('h1'..'h6').each do |header| tag = doc.at_css(header) if tag @title = tag.inner_html break end end end