Class: FeedTools::Enclosure

Inherits:
Object
  • Object
show all
Defined in:
lib/feed_tools/feed_structures.rb

Overview

This class stores information about a feed item’s file enclosures.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEnclosure

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

#bitrateObject

The bitrate of the enclosed media



148
149
150
# File 'lib/feed_tools/feed_structures.rb', line 148

def bitrate
  @bitrate
end

#categoriesObject

The categories for this enclosure



154
155
156
# File 'lib/feed_tools/feed_structures.rb', line 154

def categories
  @categories
end

#creditsObject

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_versionObject

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

#durationObject

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_sizeObject

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

#framerateObject

The framerate of the enclosed media



150
151
152
# File 'lib/feed_tools/feed_structures.rb', line 150

def framerate
  @framerate
end

#hashObject

A hash of the enclosed file



156
157
158
# File 'lib/feed_tools/feed_structures.rb', line 156

def hash
  @hash
end

#heightObject

The height in pixels of the enclosed media



144
145
146
# File 'lib/feed_tools/feed_structures.rb', line 144

def height
  @height
end

#hrefObject 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

#playerObject

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

#textObject

A text rendition of the enclosed media



163
164
165
# File 'lib/feed_tools/feed_structures.rb', line 163

def text
  @text
end

#thumbnailObject

The thumbnail for this enclosure



152
153
154
# File 'lib/feed_tools/feed_structures.rb', line 152

def thumbnail
  @thumbnail
end

#typeObject

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

#versionsObject

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

#widthObject

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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


189
190
191
# File 'lib/feed_tools/feed_structures.rb', line 189

def explicit?
  return @explicit
end

#expressionObject

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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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