Sha256: feee6ebf0e7189e4fd6490865a79a01f6a5c71d5d95d56774cd943eadb5450bb

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

module Feedjira
  module Podcast
    module Channel
      module Atom
        module InstanceMethods
          def atom
            @atom ||= Struct.new(:link).new(atom_link)
          end

          private

          def atom_link
            @atom_link ||= Struct.new(:self, :hub).new(
              atom_link_self,
              atom_link_hub,
            )
          end

          def atom_link_self
            @atom_link_self ||= Struct.new(:href, :rel, :type).new(
              atom_self_link_href,
              atom_self_link_rel,
              atom_self_link_type,
            )
          end

          def atom_link_hub
            @atom_link_hub ||= Struct.new(:href, :rel, :type).new(
              atom_hub_link_href,
              atom_hub_link_rel,
              atom_hub_link_type,
            )
          end
        end

        def self.included(base)
          base.include(InstanceMethods)

          ["self", "hub"].each do |rel|
            [:"atom:link", :"atom10:link"].each do |ns|
              base.element ns, with: { rel: rel }, as: "atom_#{rel}_link_href".to_sym, value: :href do |href|
                Addressable::URI.parse(href)
              end
              base.element ns, with: { rel: rel }, as: "atom_#{rel}_link_rel".to_sym, value: :rel
              base.element ns, with: { rel: rel }, as: "atom_#{rel}_link_type".to_sym, value: :type
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
feedjira-podcast-0.9.10 lib/feedjira/podcast/channel/atom.rb
feedjira-podcast-0.9.9 lib/feedjira/podcast/channel/atom.rb