Sha256: 43b0084ffde9bb31eb3a6df1fba6bb8893e9db7aa2c48cb673464e62166d9572

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

module Feedjira
  module Podcast
    module Channel
      module Optional
        def self.included(base)

          base.element :language
          base.element :copyright
          base.element :managingEditor, as: :managing_editor
          base.element :webMaster, as: :web_master

          base.element :pubDate, as: :pub_date do |date|
            begin
              Time.parse(date)
            rescue
              nil
            end
          end

          base.element :lastBuildDate, as: :last_build_date do |date|
            begin
              Time.parse(date)
            rescue
              nil
            end
          end

          base.elements :category

          def categories
            category.map{|c|c.strip}.uniq
          end

          base.element :generator

          base.element :docs do |docs|
            Addressable::URI.parse(docs)
          end

          # base.element :cloud

          base.element :ttl do |ttl|
            ttl.to_f
          end

          base.element :image, as: :_image, class: Image

          def image
            @image ||= Struct.new(:url, :title, :link, :width, :height, :description).new(
              _image && _image.url,
              _image && _image.title,
              _image && _image.link,
              _image && _image.width,
              _image && _image.height,
              _image && _image.description,
            )
          end

          # base.element :rating
          # base.element :skipHours
          # base.element :skipDays

        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
feedjira-podcast-0.9.0 lib/feedjira/podcast/channel/optional.rb