Sha256: dd1daa0475e3af515264d3131c7c838a41f54ca118df1d091836bf27b07cc5c1

Contents?: true

Size: 1.43 KB

Versions: 5

Compression:

Stored size: 1.43 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.strip)
              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

5 entries across 5 versions & 1 rubygems

Version Path
feedjira-podcast-0.10.0 lib/feedjira/podcast/channel/atom.rb
feedjira-podcast-0.9.14 lib/feedjira/podcast/channel/atom.rb
feedjira-podcast-0.9.13 lib/feedjira/podcast/channel/atom.rb
feedjira-podcast-0.9.12 lib/feedjira/podcast/channel/atom.rb
feedjira-podcast-0.9.11 lib/feedjira/podcast/channel/atom.rb