require 'rss'

class MotdFormatterRss

  attr_reader :content

  # @param [MotdFile] motd_file an MotdFile object that contains a URI path to a message of the day in OSC format
  def initialize(motd_file)
    feed = motd_file.content
    @content = RSS::Parser.parse(feed)
  end

  def to_partial_path
    "dashboard/motd_rss"
  end
end

require 'rss'

class MotdFormatterRss

  attr_reader :content

  # @param [MotdFile] motd_file an MotdFile object that contains a URI path to a message of the day in OSC format
  def initialize(motd_file)
    motd_file = MotdFile.new unless motd_file
    @content = parse_rss(motd_file.content)
  end

  def to_partial_path
    "dashboard/motd_rss"
  end

  private

  def parse_rss(rss_content)
    RSS::Parser.parse(rss_content)
  rescue RSS::NotWellFormedError
    Rails.logger.warn "MOTD is not parseable RSS"
    RSS::Parser.parse("")
  end
end

Move parsing to private method
Move parsing to private method
