Class: PublishingPlatformApi::Response::CacheControl

Inherits:
Hash
  • Object
show all
Defined in:
lib/publishing_platform_api/response.rb

Constant Summary collapse

PATTERN =
/([-a-z]+)(?:\s*=\s*([^,\s]+))?,?+/i

Instance Method Summary collapse

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_ageObject



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

Returns:

  • (Boolean)


46
47
48
# File 'lib/publishing_platform_api/response.rb', line 46

def must_revalidate?
  self["must-revalidate"]
end

#no_cache?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/publishing_platform_api/response.rb', line 38

def no_cache?
  self["no-cache"]
end

#no_store?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/publishing_platform_api/response.rb', line 42

def no_store?
  self["no-store"]
end

#private?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/publishing_platform_api/response.rb', line 34

def private?
  self["private"]
end

#proxy_revalidate?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/publishing_platform_api/response.rb', line 50

def proxy_revalidate?
  self["proxy-revalidate"]
end

#public?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/publishing_platform_api/response.rb', line 30

def public?
  self["public"]
end

#reverse_max_ageObject 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_ageObject 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_sObject



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