Class: PublishingPlatformApi::Response::CacheControl
- Inherits:
-
Hash
- Object
- Hash
- PublishingPlatformApi::Response::CacheControl
- Defined in:
- lib/publishing_platform_api/response.rb
Constant Summary collapse
- PATTERN =
/([-a-z]+)(?:\s*=\s*([^,\s]+))?,?+/i
Instance Method Summary collapse
-
#initialize(value = nil) ⇒ CacheControl
constructor
A new instance of CacheControl.
- #max_age ⇒ Object
- #must_revalidate? ⇒ Boolean
- #no_cache? ⇒ Boolean
- #no_store? ⇒ Boolean
- #private? ⇒ Boolean
- #proxy_revalidate? ⇒ Boolean
- #public? ⇒ Boolean
- #reverse_max_age ⇒ Object (also: #r_maxage)
- #shared_max_age ⇒ Object (also: #s_maxage)
- #to_s ⇒ Object
Constructor Details
#initialize(value = nil) ⇒ CacheControl
Returns a new instance of CacheControl.
25 26 27 28 |
# File 'lib/publishing_platform_api/response.rb', line 25 def initialize(value = nil) super() parse(value) end |
Instance Method Details
#max_age ⇒ Object
54 55 56 |
# File 'lib/publishing_platform_api/response.rb', line 54 def max_age self["max-age"].to_i if key?("max-age") end |
#must_revalidate? ⇒ Boolean
46 47 48 |
# File 'lib/publishing_platform_api/response.rb', line 46 def must_revalidate? self["must-revalidate"] end |
#no_cache? ⇒ Boolean
38 39 40 |
# File 'lib/publishing_platform_api/response.rb', line 38 def no_cache? self["no-cache"] end |
#no_store? ⇒ Boolean
42 43 44 |
# File 'lib/publishing_platform_api/response.rb', line 42 def no_store? self["no-store"] end |
#private? ⇒ Boolean
34 35 36 |
# File 'lib/publishing_platform_api/response.rb', line 34 def private? self["private"] end |
#proxy_revalidate? ⇒ Boolean
50 51 52 |
# File 'lib/publishing_platform_api/response.rb', line 50 def proxy_revalidate? self["proxy-revalidate"] end |
#public? ⇒ Boolean
30 31 32 |
# File 'lib/publishing_platform_api/response.rb', line 30 def public? self["public"] end |
#reverse_max_age ⇒ Object Also known as: r_maxage
58 59 60 |
# File 'lib/publishing_platform_api/response.rb', line 58 def reverse_max_age self["r-maxage"].to_i if key?("r-maxage") end |
#shared_max_age ⇒ Object Also known as: s_maxage
63 64 65 |
# File 'lib/publishing_platform_api/response.rb', line 63 def shared_max_age self["s-maxage"].to_i if key?("r-maxage") end |
#to_s ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/publishing_platform_api/response.rb', line 68 def to_s directives = [] values = [] each do |key, value| if value == true directives << key elsif value values << "#{key}=#{value}" end end (directives.sort + values.sort).join(", ") end |