Class: Xenon::Headers::IfRange
Overview
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#etag ⇒ Object
readonly
Returns the value of attribute etag.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value) ⇒ IfRange
constructor
A new instance of IfRange.
- #to_s ⇒ Object
Constructor Details
#initialize(value) ⇒ IfRange
Returns a new instance of IfRange.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/xenon/headers/if_range.rb', line 12 def initialize(value) case value when Time, DateTime, Date then @date = value when ETag then @etag = value when String then @etag = ETag.parse(value) else raise ArgumentError, 'Value must be a time or an etag.' end raise ProtocolError, 'If-Range headers must use strong ETags.' if @etag && @etag.weak? end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
10 11 12 |
# File 'lib/xenon/headers/if_range.rb', line 10 def date @date end |
#etag ⇒ Object (readonly)
Returns the value of attribute etag.
10 11 12 |
# File 'lib/xenon/headers/if_range.rb', line 10 def etag @etag end |
Class Method Details
.parse(s) ⇒ Object
23 24 25 26 |
# File 'lib/xenon/headers/if_range.rb', line 23 def self.parse(s) tree = Parsers::IfRangeHeader.new.parse(s) Parsers::IfRangeHeaderTransform.new.apply(tree) end |
Instance Method Details
#to_s ⇒ Object
28 29 30 |
# File 'lib/xenon/headers/if_range.rb', line 28 def to_s @etag ? @etag.to_s : @date.httpdate end |