class Hermeneutics::Contents
A parser for header fields in Content-Type style
Example¶ ↑
content_disposition = Contents.new "form-data", name: "mycontrol" content_type = Contents.parse "text/html; boundary=0123456" content_type.caption #=> "text/html" content_type[ :boundary] #=> "0123456" # (Subclass ContentType even splits the caption into type/subtype.)
Attributes
caption[R]
Public Class Methods
new(caption, hash = nil)
click to toggle source
Create a Contents
object from a value and a hash.
c = Contents.new "text/html", boundary: "0123456"
Calls superclass method
Hermeneutics::Dictionary::new
# File lib/hermeneutics/contents.rb, line 251 def initialize caption, hash = nil if caption =~ RES or caption =~ REA then raise "Invalid content caption '#{caption}'." end @caption = caption.new_string super hash end
parse(line)
click to toggle source
Create a Contents
object out of a string from a mail header field.
c = Contents.parse "text/html; boundary=0123456" c.caption #=> "text/html" c[ :boundary] #=> "0123456"
# File lib/hermeneutics/contents.rb, line 236 def parse line rest = line.strip caption, rest = rest.split Dictionary::RES, 2 hash = parse_hash rest new caption, hash end
Public Instance Methods
=~(re)
click to toggle source
# File lib/hermeneutics/contents.rb, line 259 def =~ re @caption =~ re end
encoded_parts()
click to toggle source
Calls superclass method
# File lib/hermeneutics/contents.rb, line 270 def encoded_parts r = [ "#@caption"] r.concat super r end
quoted_parts()
click to toggle source
Calls superclass method
# File lib/hermeneutics/contents.rb, line 264 def quoted_parts r = [ "#@caption"] r.concat super r end