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
#=~, #encoded_parts, parse, #quoted_parts
Methods inherited from Dictionary
#[], #encode, #keys, #method_missing, 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"
285 286 287 288 |
# File 'lib/hermeneutics/contents.rb', line 285 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"
312 |
# File 'lib/hermeneutics/contents.rb', line 312 def fulltype ; ; end |
#parse_mime(input) ⇒ Object
328 329 330 331 |
# File 'lib/hermeneutics/contents.rb', line 328 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"
300 |
# File 'lib/hermeneutics/contents.rb', line 300 def split_type ; @split ||= (@caption.split "/", 2) ; end |
#subtype ⇒ Object
:call-seq:
subtype -> str
See fulltype
or split_type
.
326 |
# File 'lib/hermeneutics/contents.rb', line 326 def subtype ; split_type.last ; end |
#type ⇒ Object
:call-seq:
type -> str
See fulltype
or split_type
.
319 |
# File 'lib/hermeneutics/contents.rb', line 319 def type ; split_type.first ; end |