【发布时间】:2012-04-30 05:31:57
【问题描述】:
我正在使用 Tmail 库,对于电子邮件中的每个附件,当我使用attachment.content_type 时,有时我不仅会得到内容类型,还会得到名称。例子:
image/jpeg; name=example3.jpg
image/jpeg; name=example.jpg
image/jpeg; name=photo.JPG
image/png
我有一组像这样的有效内容类型:
VALID_CONTENT_TYPES = ['image/jpeg']
我希望能够检查内容类型是否包含在任何有效的内容类型数组元素中。
在 Ruby 中这样做的最佳方式是什么?
【问题讨论】: