Class: Keystone::Mail::ContentType
- Defined in:
- lib/keystone/mail__old/content_type.rb
Instance Attribute Summary collapse
-
#boundary ⇒ Object
Returns the value of attribute boundary.
-
#charset ⇒ Object
Returns the value of attribute charset.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
Instance Method Summary collapse
- #get_boundary(st) ⇒ Object
-
#initialize(st) ⇒ ContentType
constructor
A new instance of ContentType.
Constructor Details
#initialize(st) ⇒ ContentType
Returns a new instance of ContentType.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/keystone/mail__old/content_type.rb', line 13 def initialize(st) if /text\/plain/i =~ st @content_type = :text_plain if /charset="?iso-2022-jp"?/i =~ st @charset = :iso_2022_jp elsif /charset="?utf-8"?/i =~ st @charset = :utf_8 end elsif /multipart\/mixed/i =~ st @content_type = :multipart_mixed @boundary = get_boundary(st) elsif /multipart\/related/i =~ st @content_type = :multipart_related @boundary = get_boundary(st) elsif /multipart\/alternative/i =~ st @content_type = :multipart_alternative @boundary = get_boundary(st) elsif /text\/html/i =~ st @content_type = :text_html if /charset="?iso-2022-jp"?/i =~ st @charset = :iso_2022_jp elsif /charset="?utf-8"?/i =~ st @charset = :utf_8 end else if /image\/(?:jpeg|jpg)/i =~ st @content_type = :image_jpeg elsif /image\/png/i =~ st @content_type = :image_png elsif /image\/gif/i =~ st @content_type = :image_gif else throw "this image does not support[#{st}]" end end end |
Instance Attribute Details
#boundary ⇒ Object
Returns the value of attribute boundary.
12 13 14 |
# File 'lib/keystone/mail__old/content_type.rb', line 12 def boundary @boundary end |
#charset ⇒ Object
Returns the value of attribute charset.
12 13 14 |
# File 'lib/keystone/mail__old/content_type.rb', line 12 def charset @charset end |
#content_type ⇒ Object
Returns the value of attribute content_type.
12 13 14 |
# File 'lib/keystone/mail__old/content_type.rb', line 12 def content_type @content_type end |
Instance Method Details
#get_boundary(st) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/keystone/mail__old/content_type.rb', line 50 def get_boundary(st) # TODO modify regular expression if /boundary="(.*)"/i =~ st return $1 elsif /boundary=(.*)/i =~ st return $1 end return nil end |