class Webmachine::ETag
A wrapper around entity tags that encapsulates their semantics. This class by itself represents a “strong” entity tag.
Constants
- WEAK_ETAG
The pattern for a weak entity tag
Attributes
etag[R]
Public Class Methods
new(etag)
click to toggle source
# File lib/webmachine/etags.rb, line 11 def self.new(etag) return etag if ETag === etag klass = WEAK_ETAG.match?(etag) ? WeakETag : self klass.send(:allocate).tap do |obj| obj.send(:initialize, etag) end end
new(etag)
click to toggle source
# File lib/webmachine/etags.rb, line 21 def initialize(etag) @etag = quote(etag) end
Public Instance Methods
==(other)
click to toggle source
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
.
# 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()
click to toggle source
Converts the entity tag into a string appropriate for use in a header.
# File lib/webmachine/etags.rb, line 39 def to_s quote @etag end