Class: InternetMessage::ContentDisposition
- Inherits:
-
Object
- Object
- InternetMessage::ContentDisposition
- Defined in:
- lib/internet_message/content_disposition.rb
Constant Summary collapse
- TOKEN_RE =
/[0-9a-zA-Z\!\#\$\%\&\'\*\+\-\.\^\_\`\{\|\}\~]+/i
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#==(other) ⇒ true, false
Compare self and other.
-
#initialize(type, attribute = {}) ⇒ ContentDisposition
constructor
A new instance of ContentDisposition.
Constructor Details
#initialize(type, attribute = {}) ⇒ ContentDisposition
Returns a new instance of ContentDisposition.
26 27 28 |
# File 'lib/internet_message/content_disposition.rb', line 26 def initialize(type, attribute={}) @type, @attribute = type.downcase, attribute end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
22 23 24 |
# File 'lib/internet_message/content_disposition.rb', line 22 def attribute @attribute end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
22 23 24 |
# File 'lib/internet_message/content_disposition.rb', line 22 def type @type end |
Class Method Details
.parse(src) ⇒ ContentDisposition
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/internet_message/content_disposition.rb', line 11 def self.parse(src) tokens = src.is_a?(String) ? Tokenizer.new(src, :token_re=>TOKEN_RE).tokenize : src.dup tokens.delete_if{|t| t.type == :WSP or t.type == :COMMENT} unless tokens.size >= 1 && tokens[0].type == :TOKEN return nil end type = tokens[0].value tokens.shift ContentDisposition.new(type, ContentAttribute.parse_attribute(tokens)) end |
Instance Method Details
#==(other) ⇒ true, false
Compare self and other.
33 34 35 |
# File 'lib/internet_message/content_disposition.rb', line 33 def ==(other) other.is_a?(ContentDisposition) && other.type == self.type && other.attribute == self.attribute end |