class Atom::MediaType
MediaType
¶ ↑
Class represents MediaType
Accessors¶ ↑
feed = Atom::MediaType.new 'application/atom+xml;type=feed' puts feed.type # application puts feed.subtype # atom+xml puts feed.subtype_major # xml puts feed.without_parameters # application/atom+xml puts feed.parameters # type=feed puts feed.to_s # application/atom+xml;type=feed
Equivalence¶ ↑
feed2 = Atom::MediaType.new 'application/atom+xml;type=feed' entry = Atom::MediaType.new 'application/atom+xml;type=entry' feed == feed2 # -> true feed == entry # -> false feed == 'application/atom+xml;type=feed' # -> true
Constants¶ ↑
Major media types for atom syndication format are already prepared. Use following constants for them.
Atom::MediaType::SERVICE
-
application/atomsvc+xml
Atom::MediaType::CATEGORIES
-
application/atomcat+xml
Atom::MediaType::FEED
-
application/atom+xml;type=feed
Atom::MediaType::ENTRY
-
application/atom+xml;type=entry
Constants
- CATEGORIES
- ENTRY
- FEED
- SERVICE
Attributes
parameters[R]
subtype[R]
type[R]
Public Instance Methods
==(value)
click to toggle source
# File lib/atomutil.rb, line 205 def ==(value) if value.is_a?(MediaType) to_s == value.to_s else to_s == value end end
is_a?(value)
click to toggle source
# File lib/atomutil.rb, line 213 def is_a?(value) value = self.class.new value unless value.instance_of?(self.class) return true if value.type == '*' return false unless value.type == @type return true if value.subtype == '*' return false unless value.subtype == @subtype return true if value.parameters.nil? || @parameters.nil? return value.parameters == @parameters end
subtype_major()
click to toggle source
# File lib/atomutil.rb, line 193 def subtype_major @subtype =~ /\+(.+)/ ? $1 : @subtype end
to_s()
click to toggle source
# File lib/atomutil.rb, line 201 def to_s [without_parameters, @parameters].select{ |p| !p.nil? }.join(";") end
without_parameters()
click to toggle source
# File lib/atomutil.rb, line 197 def without_parameters "#{@type}/#{@subtype}" end