Class: GdsApi::Response::CacheControl
- Inherits:
-
Hash
- Object
- Hash
- GdsApi::Response::CacheControl
- Defined in:
- lib/gds_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.
26 27 28 29 |
# File 'lib/gds_api/response.rb', line 26 def initialize(value = nil) super() parse(value) end |
Instance Method Details
#max_age ⇒ Object
55 56 57 |
# File 'lib/gds_api/response.rb', line 55 def max_age self["max-age"].to_i if key?("max-age") end |
#must_revalidate? ⇒ Boolean
47 48 49 |
# File 'lib/gds_api/response.rb', line 47 def must_revalidate? self["must-revalidate"] end |
#no_cache? ⇒ Boolean
39 40 41 |
# File 'lib/gds_api/response.rb', line 39 def no_cache? self["no-cache"] end |
#no_store? ⇒ Boolean
43 44 45 |
# File 'lib/gds_api/response.rb', line 43 def no_store? self["no-store"] end |
#private? ⇒ Boolean
35 36 37 |
# File 'lib/gds_api/response.rb', line 35 def private? self["private"] end |
#proxy_revalidate? ⇒ Boolean
51 52 53 |
# File 'lib/gds_api/response.rb', line 51 def proxy_revalidate? self["proxy-revalidate"] end |
#public? ⇒ Boolean
31 32 33 |
# File 'lib/gds_api/response.rb', line 31 def public? self["public"] end |
#reverse_max_age ⇒ Object Also known as: r_maxage
59 60 61 |
# File 'lib/gds_api/response.rb', line 59 def reverse_max_age self["r-maxage"].to_i if key?("r-maxage") end |
#shared_max_age ⇒ Object Also known as: s_maxage
64 65 66 |
# File 'lib/gds_api/response.rb', line 64 def shared_max_age self["s-maxage"].to_i if key?("r-maxage") end |
#to_s ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/gds_api/response.rb', line 69 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 |