class Hermes::ContentType

Public Class Methods

new( str) → cts click to toggle source

Create a ContentType object either out of a string from an E-Mail header field or from a value and a hash.

c = ContentType.parse "text/html; boundary=0123456"
c = ContentType.new "text/html", :boundary => "0123456"
Calls superclass method Hermes::Contents.new
# File lib/hermes/contents.rb, line 284
def initialize line, sf = nil
  line = line.join "/" if Array === line
  super
end

Public Instance Methods

fulltype → str click to toggle source

Find caption value of Content-Type style header field.

c = ContentType.new "text/html; boundary=0123456"
c.fulltype       #=>  "text/html"
c.type           #=>  "text"
c.subtype        #=>  "html"
# File lib/hermes/contents.rb, line 311
def fulltype ; caption ; end
parse_mime(input) click to toggle source
# File lib/hermes/contents.rb, line 327
def parse_mime input
  m = Mime.find @caption
  m and m.parse input, @hash
end
split_type → str click to toggle source

Find caption value of Content-Type style header field as an array

c = ContentType.new "text/html; boundary=0123456"
c.split_type       #=>  [ "text", "html"]
c.type           #=>  "text"
c.subtype        #=>  "html"
# File lib/hermes/contents.rb, line 299
def split_type ; @split ||= (@caption.split "/", 2) ; end
subtype → str click to toggle source

See fulltype or split_type.

# File lib/hermes/contents.rb, line 325
def subtype ; split_type.last  ; end
type → str click to toggle source

See fulltype or split_type.

# File lib/hermes/contents.rb, line 318
def type    ; split_type.first ; end