Sha256: 23fd4408f1e4aaf22ec87adecbc838053cd5eac2889771a5ebc30a15970b6a9b

Contents?: true

Size: 544 Bytes

Versions: 11

Compression:

Stored size: 544 Bytes

Contents

require 'xommelier/atom'

module Xommelier
  module Atom
    module LinksExtension
      def feed_url
        detect_linked_href(rel: 'self', type: 'application/atom+xml')
      end

      def html_url
        detect_linked_href(rel: 'alternate', type: 'text/html')
      end

      protected

      def detect_linked_href(attributes = {})
        links.detect do |link|
          attributes.inject(true) do |result, (attr, value)|
            result && link.send(attr) == value
          end
        end.try(:href)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
xommelier-0.1.30 lib/xommelier/atom/links_extension.rb
xommelier-0.1.29 lib/xommelier/atom/links_extension.rb
xommelier-0.1.28 lib/xommelier/atom/links_extension.rb
xommelier-0.1.27 lib/xommelier/atom/links_extension.rb
xommelier-0.1.26 lib/xommelier/atom/links_extension.rb
xommelier-0.1.25 lib/xommelier/atom/links_extension.rb
xommelier-0.1.24 lib/xommelier/atom/links_extension.rb
xommelier-0.1.23 lib/xommelier/atom/links_extension.rb
xommelier-0.1.22 lib/xommelier/atom/links_extension.rb
xommelier-0.1.21 lib/xommelier/atom/links_extension.rb
xommelier-0.1.20 lib/xommelier/atom/links_extension.rb