Class: FeedNormalizer::Parser

### Home Classes Methods

### In Files

- lib/feed-normalizer.rb

### Parent

Object

### Methods

- ::append_or_set!
- ::map_functions!
- ::parse
- ::parser
- ::priority

### Files

- History.txt
- License.txt
- Manifest.txt
- README.txt

### Class/Module Index

Quicksearch

- FeedNormalizer
- FeedNormalizer::ElementCleaner
- FeedNormalizer::ElementEquality
- FeedNormalizer::Entry
- FeedNormalizer::Feed
- FeedNormalizer::FeedNormalizer
- FeedNormalizer::HtmlCleaner
- FeedNormalizer::Parser
- FeedNormalizer::ParserRegistry
- FeedNormalizer::RewriteRelativeLinks
- FeedNormalizer::RubyRssParser
- FeedNormalizer::SimpleRssParser
- FeedNormalizer::Singular
- FeedNormalizer::TimeFix
- RSS
- RSS::Rss
- RSS::Rss::Channel
- RSS::Rss::Channel::Item
- RSS::Rss::Channel::Item::Enclosure
- SimpleRSS

No matching classes.

# FeedNormalizer::Parser

The root parser object. Every parser must extend this object.

### Public Class Methods

parse(feed, loose) click to toggle source

Parses the given feed, and returns a normalized representation. Returns nil if the feed could not be parsed.

    # File lib/feed-normalizer.rb, line 16
    def self.parse(feed, loose)
      nil
    end

parser() click to toggle source

Parser being used.

    # File lib/feed-normalizer.rb, line 10
    def self.parser
      nil
    end

priority() click to toggle source

Returns a number to indicate parser priority. The lower the number, the more likely the parser will be used first, and vice-versa.

    # File lib/feed-normalizer.rb, line 23
    def self.priority
      0
    end

### Protected Class Methods

append_or_set!(value, object, object_function) click to toggle source

    # File lib/feed-normalizer.rb, line 53
    def self.append_or_set!(value, object, object_function)
      if object.send(object_function).respond_to? :push
        object.send(object_function).push(value)
      else
        object.send(:"#{object_function}=", value)
      end
    end

map_functions!(mapping, src, dest) click to toggle source

sets value, or appends to an existing value

    # File lib/feed-normalizer.rb, line 32
    def self.map_functions!(mapping, src, dest)

      mapping.each do |dest_function, src_functions|
        src_functions = [src_functions].flatten # pack into array

        src_functions.each do |src_function|
          value = if src.respond_to?(src_function)
            src.send(src_function)
          elsif src.respond_to?(:has_key?)
            src[src_function]
          end

          unless value.to_s.empty?
            append_or_set!(value, dest, dest_function)
            break
          end
        end

      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.