Class: HttpObjects::Parameters::EntityTags

Inherits:
BasicRules::Base show all
Defined in:
lib/http_objects/parameters/entity_tags.rb

Overview

3.11 Entity Tags

Examples

"123456789"    -- A strong ETag validator
W/"123456789"  -- A weak ETag validator

Instance Attribute Summary

Attributes inherited from BasicRules::Base

#raw, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BasicRules::Base

#initialize

Constructor Details

This class inherits a constructor from HttpObjects::Parameters::BasicRules::Base

Class Method Details

.parse(value) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/http_objects/parameters/entity_tags.rb', line 10

def self.parse(value)
  raw = value
  if (match = value.match(/("\w*")/))
    value = match[1]
  else
    value = ""
  end
  self.new(raw, value.to_s)
end

Instance Method Details

#weak?Boolean

Returns true if raw start with ‘W/’

Returns:

  • (Boolean)


21
22
23
# File 'lib/http_objects/parameters/entity_tags.rb', line 21

def weak?
  @raw.start_with?("W/")
end