Module: Feedjira::AtomEntryUtilities

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/feedjira/atom_entry_utilities.rb', line 5

def self.included(mod)
  mod.class_exec do
    element :title, as: :raw_title, with: { type: "html" }
    element :title, as: :raw_title, with: { type: "xhtml" }
    element :title, as: :raw_title, with: { type: "xml" }
    element :title, as: :title, with: { type: "text" }
    element :title, as: :title, with: { type: nil }
    element :title, as: :title_type, value: :type

    element :name, as: :author
    element :content
    element :summary
    element :enclosure, as: :image, value: :href

    element :published
    element :id, as: :entry_id
    element :created, as: :published
    element :issued, as: :published
    element :updated
    element :modified, as: :updated

    elements :category, as: :categories, value: :term

    element :link, as: :url, value: :href, with: {
      type: "text/html",
      rel: "alternate"
    }

    elements :link, as: :links, value: :href
  end
end

Instance Method Details

#titleObject


37
38
39
40
41
42
43
44
45
# File 'lib/feedjira/atom_entry_utilities.rb', line 37

def title
  @title ||=
    case @raw_title
    when String
      Loofah.fragment(@raw_title).xpath("normalize-space(.)")
    else
      @title
    end
end

#urlObject


47
48
49
# File 'lib/feedjira/atom_entry_utilities.rb', line 47

def url
  @url ||= links.first
end