Class: FeedTools::Enclosure
- Inherits:
-
Object
- Object
- FeedTools::Enclosure
- Defined in:
- lib/feed_tools/feed_structures.rb
Overview
This class stores information about a feed item’s file enclosures.
Instance Attribute Summary collapse
-
#bitrate ⇒ Object
The bitrate of the enclosed media.
-
#categories ⇒ Object
The categories for this enclosure.
-
#credits ⇒ Object
A list of credits for the enclosed media.
-
#default_version ⇒ Object
The default version of the enclosed media file.
-
#duration ⇒ Object
The total play time of the file referenced by the enclosure.
-
#file_size ⇒ Object
The size of the file referenced by the enclosure.
-
#framerate ⇒ Object
The framerate of the enclosed media.
-
#hash ⇒ Object
A hash of the enclosed file.
-
#height ⇒ Object
The height in pixels of the enclosed media.
-
#href ⇒ Object
(also: #url, #link)
The url for the enclosure.
-
#player ⇒ Object
A website containing some kind of media player instead of a direct link to the media file.
-
#text ⇒ Object
A text rendition of the enclosed media.
-
#thumbnail ⇒ Object
The thumbnail for this enclosure.
-
#type ⇒ Object
The MIME type of the file referenced by the enclosure.
-
#versions ⇒ Object
A list of alternate version of the enclosed media file.
-
#width ⇒ Object
The width in pixels of the enclosed media.
Instance Method Summary collapse
-
#audio? ⇒ Boolean
Returns true if this enclosure contains audio content.
-
#explicit=(new_explicit) ⇒ Object
Sets the explicit attribute on the enclosure.
-
#explicit? ⇒ Boolean
Returns true if the enclosure contains explicit material.
-
#expression ⇒ Object
Determines if the object is a sample, or the full version of the object, or if it is a stream.
-
#expression=(new_expression) ⇒ Object
Sets the expression attribute on the enclosure.
-
#initialize ⇒ Enclosure
constructor
A new instance of Enclosure.
-
#is_default=(new_is_default) ⇒ Object
Sets whether this is the default enclosure for the media group.
-
#is_default? ⇒ Boolean
Returns true if this is the default enclosure.
-
#video? ⇒ Boolean
Returns true if this enclosure contains video content.
Constructor Details
#initialize ⇒ Enclosure
Returns a new instance of Enclosure.
174 175 176 |
# File 'lib/feed_tools/feed_structures.rb', line 174 def initialize @expression = 'full' end |
Instance Attribute Details
#bitrate ⇒ Object
The bitrate of the enclosed media
148 149 150 |
# File 'lib/feed_tools/feed_structures.rb', line 148 def bitrate @bitrate end |
#categories ⇒ Object
The categories for this enclosure
154 155 156 |
# File 'lib/feed_tools/feed_structures.rb', line 154 def categories @categories end |
#credits ⇒ Object
A list of credits for the enclosed media
161 162 163 |
# File 'lib/feed_tools/feed_structures.rb', line 161 def credits @credits end |
#default_version ⇒ Object
The default version of the enclosed media file
167 168 169 |
# File 'lib/feed_tools/feed_structures.rb', line 167 def default_version @default_version end |
#duration ⇒ Object
The total play time of the file referenced by the enclosure
142 143 144 |
# File 'lib/feed_tools/feed_structures.rb', line 142 def duration @duration end |
#file_size ⇒ Object
The size of the file referenced by the enclosure
140 141 142 |
# File 'lib/feed_tools/feed_structures.rb', line 140 def file_size @file_size end |
#framerate ⇒ Object
The framerate of the enclosed media
150 151 152 |
# File 'lib/feed_tools/feed_structures.rb', line 150 def framerate @framerate end |
#hash ⇒ Object
A hash of the enclosed file
156 157 158 |
# File 'lib/feed_tools/feed_structures.rb', line 156 def hash @hash end |
#height ⇒ Object
The height in pixels of the enclosed media
144 145 146 |
# File 'lib/feed_tools/feed_structures.rb', line 144 def height @height end |
#href ⇒ Object Also known as: url, link
The url for the enclosure
136 137 138 |
# File 'lib/feed_tools/feed_structures.rb', line 136 def href @href end |
#player ⇒ Object
A website containing some kind of media player instead of a direct link to the media file.
159 160 161 |
# File 'lib/feed_tools/feed_structures.rb', line 159 def player @player end |
#text ⇒ Object
A text rendition of the enclosed media
163 164 165 |
# File 'lib/feed_tools/feed_structures.rb', line 163 def text @text end |
#thumbnail ⇒ Object
The thumbnail for this enclosure
152 153 154 |
# File 'lib/feed_tools/feed_structures.rb', line 152 def thumbnail @thumbnail end |
#type ⇒ Object
The MIME type of the file referenced by the enclosure
138 139 140 |
# File 'lib/feed_tools/feed_structures.rb', line 138 def type @type end |
#versions ⇒ Object
A list of alternate version of the enclosed media file
165 166 167 |
# File 'lib/feed_tools/feed_structures.rb', line 165 def versions @versions end |
#width ⇒ Object
The width in pixels of the enclosed media
146 147 148 |
# File 'lib/feed_tools/feed_structures.rb', line 146 def width @width end |
Instance Method Details
#audio? ⇒ Boolean
Returns true if this enclosure contains audio content
215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/feed_tools/feed_structures.rb', line 215 def audio? unless self.type.nil? return true if (self.type =~ /^audio/) != nil end # TODO: create a more complete list # ================================= audio_extensions = ['mp3', 'm4a', 'm4p', 'wav', 'ogg', 'wma'] audio_extensions.each do |extension| if (url =~ /#{extension}$/) != nil return true end end return false end |
#explicit=(new_explicit) ⇒ Object
Sets the explicit attribute on the enclosure
194 195 196 |
# File 'lib/feed_tools/feed_structures.rb', line 194 def explicit=(new_explicit) @explicit = new_explicit end |
#explicit? ⇒ Boolean
Returns true if the enclosure contains explicit material
189 190 191 |
# File 'lib/feed_tools/feed_structures.rb', line 189 def explicit? return @explicit end |
#expression ⇒ Object
Determines if the object is a sample, or the full version of the object, or if it is a stream. Possible values are ‘sample’, ‘full’, ‘nonstop’.
201 202 203 |
# File 'lib/feed_tools/feed_structures.rb', line 201 def expression return @expression end |
#expression=(new_expression) ⇒ Object
Sets the expression attribute on the enclosure. Allowed values are ‘sample’, ‘full’, ‘nonstop’.
207 208 209 210 211 212 |
# File 'lib/feed_tools/feed_structures.rb', line 207 def expression=(new_expression) unless ['sample', 'full', 'nonstop'].include? new_expression.downcase return @expression end @expression = new_expression.downcase end |
#is_default=(new_is_default) ⇒ Object
Sets whether this is the default enclosure for the media group
184 185 186 |
# File 'lib/feed_tools/feed_structures.rb', line 184 def is_default=(new_is_default) @is_default = new_is_default end |
#is_default? ⇒ Boolean
Returns true if this is the default enclosure
179 180 181 |
# File 'lib/feed_tools/feed_structures.rb', line 179 def is_default? return @is_default end |
#video? ⇒ Boolean
Returns true if this enclosure contains video content
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/feed_tools/feed_structures.rb', line 231 def video? unless self.type.nil? return true if (self.type =~ /^video/) != nil return true if self.type == "image/mov" end # TODO: create a more complete list # ================================= video_extensions = ['mov', 'mp4', 'avi', 'wmv', 'asf'] video_extensions.each do |extension| if (url =~ /#{extension}$/) != nil return true end end return false end |