Class: Hermeneutics::ContentType
- Inherits:
-
Contents
- Object
- Dictionary
- Contents
- Hermeneutics::ContentType
- Defined in:
- lib/hermeneutics/contents.rb
Constant Summary
Constants inherited from Dictionary
Dictionary::REA, Dictionary::RES, Dictionary::SEA, Dictionary::SEP, Dictionary::TSPECIAL
Instance Attribute Summary
Attributes inherited from Contents
Attributes inherited from Dictionary
Instance Method Summary collapse
-
#fulltype ⇒ Object
:call-seq: fulltype -> str.
-
#initialize(line, sf = nil) ⇒ ContentType
constructor
:call-seq: new( str) -> cts.
- #parse_mime(input) ⇒ Object
-
#split_type ⇒ Object
:call-seq: split_type -> str.
-
#subtype ⇒ Object
:call-seq: subtype -> str.
-
#type ⇒ Object
:call-seq: type -> str.
Methods inherited from Contents
#=~, #empty?, #encoded_parts, #notempty?, parse, #quoted_parts
Methods inherited from Dictionary
#[], #empty?, #encode, #keys, #notempty?, parse, #to_s, urltext
Constructor Details
#initialize(line, sf = nil) ⇒ ContentType
:call-seq:
new( str) -> cts
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"
295 296 297 298 |
# File 'lib/hermeneutics/contents.rb', line 295 def initialize line, sf = nil line = line.join "/" if Array === line super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Hermeneutics::Dictionary
Instance Method Details
#fulltype ⇒ Object
:call-seq:
fulltype -> str
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"
322 |
# File 'lib/hermeneutics/contents.rb', line 322 def fulltype ; caption ; end |
#parse_mime(input) ⇒ Object
338 339 340 341 |
# File 'lib/hermeneutics/contents.rb', line 338 def parse_mime input m = Mime.find @caption m and m.parse input, **@hash end |
#split_type ⇒ Object
:call-seq:
split_type -> str
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"
310 |
# File 'lib/hermeneutics/contents.rb', line 310 def split_type ; @split ||= (@caption.split "/", 2) ; end |
#subtype ⇒ Object
:call-seq:
subtype -> str
See fulltype or split_type.
336 |
# File 'lib/hermeneutics/contents.rb', line 336 def subtype ; split_type.last ; end |
#type ⇒ Object
:call-seq:
type -> str
See fulltype or split_type.
329 |
# File 'lib/hermeneutics/contents.rb', line 329 def type ; split_type.first ; end |