Class: XML::MappingExtensions::MimeTypeNode
- Inherits:
-
NodeBase
- Object
- XML::Mapping::SingleAttributeNode
- NodeBase
- XML::MappingExtensions::MimeTypeNode
- Defined in:
- lib/xml/mapping_extensions/mime_type_node.rb
Overview
Converts MIME type strings to MIME::Type
objects
Instance Method Summary collapse
-
#to_value(xml_text) ⇒ MIME::Type
Converts a MIME type string to a
MIME::Type
object, either the first corresponding value in theMIME::Types
registry, or a newly created value.
Methods inherited from NodeBase
#extract_attr_value, #initialize, #set_attr_value, #to_xml_text
Constructor Details
This class inherits a constructor from XML::MappingExtensions::NodeBase
Instance Method Details
#to_value(xml_text) ⇒ MIME::Type
Converts a MIME type string to a MIME::Type
object,
either the first corresponding value in the MIME::Types
registry, or a newly created value.
16 17 18 19 20 21 22 |
# File 'lib/xml/mapping_extensions/mime_type_node.rb', line 16 def to_value(xml_text) if (mt = MIME::Types[xml_text].first) mt else MIME::Type.new(xml_text) end end |