Module: TinyAtom

Defined in:
lib/tinyatom/uri_domain.rb,
lib/tinyatom/feed.rb,
lib/tinyatom/version.rb

Overview

URI mixin that adds method to get domain.

Defined Under Namespace

Modules: URIDomain Classes: Feed

Constant Summary collapse

EnclosureOptionalAttrs =

param name => tag name

{
:enclosure_length => :length,
}
MediaThumbnailOptionalAttrs =

param name => tag name

{
:media_thumbnail_height => :height,
:media_thumbnail_width => :width,
:media_thumbnail_time => :time,
}
VERSION =
'0.3.6'

Class Method Summary collapse

Class Method Details

.author(markup, h) ⇒ Object

Add author tags if present.



86
87
88
89
90
91
92
93
94
# File 'lib/tinyatom/feed.rb', line 86

def author(markup, h)
  if h[:author_name]
    markup.author {
      markup.name h[:author_name]
      markup.email(h[:author_email])  if h[:author_email]
      markup.uri(h[:author_uri])  if h[:author_uri]
    }
  end
end

.enclosure(markup, h) ⇒ Object

Add enclosure tags if present.



102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/tinyatom/feed.rb', line 102

def enclosure(markup, h)
  if h[:enclosure_type] and h[:enclosure_href] and h[:enclosure_title]
    options = {}
    h.each do |k,v|
      if EnclosureOptionalAttrs.include?(k)
        options[EnclosureOptionalAttrs[k]] = v
      end
    end

    link markup, 'enclosure', h[:enclosure_type], h[:enclosure_href],
      h[:enclosure_title], options
  end
end

Create link tag.



146
147
148
149
150
151
152
153
# File 'lib/tinyatom/feed.rb', line 146

def link(markup, rel, type, href, title, options={})
  markup.link({
    :rel => rel,
    :type => type,
    :href => href,
    :title => title
    }.merge(options))
end

.media_thumbnail(markup, h) ⇒ Object

Add media:thumbnail tags if present.



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/tinyatom/feed.rb', line 124

def media_thumbnail(markup, h)
  if h[:media_thumbnail_url]
    options = {}
    h.each do |k,v|
      if MediaThumbnailOptionalAttrs.include?(k)
        options[MediaThumbnailOptionalAttrs[k]] = v
      end
    end

    markup.media :thumbnail,
      { :url => h[:media_thumbnail_url] }.merge(options)
  end
end

.via(markup, h) ⇒ Object

Add via tags if present.



139
140
141
142
143
# File 'lib/tinyatom/feed.rb', line 139

def via(markup, h)
  if h[:via_type] and h[:via_href] and h[:via_title]
    link markup, 'via', h[:via_type], h[:via_href], h[:via_title]
  end
end