Class: Webmachine::ETag
- Inherits:
-
Object
- Object
- Webmachine::ETag
- Includes:
- QuotedString
- Defined in:
- lib/webmachine/etags.rb
Overview
A wrapper around entity tags that encapsulates their semantics. This class by itself represents a “strong” entity tag.
Direct Known Subclasses
Constant Summary collapse
- WEAK_ETAG =
The pattern for a weak entity tag
/^W\/#{QUOTED_STRING}$/.freeze
Constants included from QuotedString
QuotedString::QS_ANCHORED, QuotedString::QUOTED_STRING
Instance Attribute Summary collapse
-
#etag ⇒ Object
readonly
Returns the value of attribute etag.
Class Method Summary collapse
Instance Method Summary collapse
-
#==(other) ⇒ Object
An entity tag is equivalent to another entity tag if their quoted values are equivalent.
-
#initialize(etag) ⇒ ETag
constructor
A new instance of ETag.
-
#to_s ⇒ Object
Converts the entity tag into a string appropriate for use in a header.
Methods included from QuotedString
#escape_quotes, #quote, #unescape_quotes, #unquote
Constructor Details
#initialize(etag) ⇒ ETag
Returns a new instance of ETag.
21 22 23 |
# File 'lib/webmachine/etags.rb', line 21 def initialize(etag) @etag = quote(etag) end |
Instance Attribute Details
#etag ⇒ Object (readonly)
Returns the value of attribute etag.
19 20 21 |
# File 'lib/webmachine/etags.rb', line 19 def etag @etag end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
An entity tag is equivalent to another entity tag if their quoted values are equivalent. It is also equivalent to a String which represents the equivalent ETag.
28 29 30 31 32 33 34 35 |
# File 'lib/webmachine/etags.rb', line 28 def ==(other) case other when ETag other.etag == @etag when String quote(other) == @etag end end |
#to_s ⇒ Object
Converts the entity tag into a string appropriate for use in a header.
39 40 41 |
# File 'lib/webmachine/etags.rb', line 39 def to_s quote @etag end |