Class: Bidi2pdf::Bidi::Commands::SetTabCookie

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/bidi2pdf/bidi/commands/set_tab_cookie.rb

Direct Known Subclasses

SetUsercontextCookie

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base

#==, #as_payload, #eql?, #hash, #inspect

Constructor Details

#initialize(name:, value:, domain:, browsing_context_id:, path: "/", secure: true, http_only: false, same_site: "strict", ttl: 30) ⇒ SetTabCookie

Returns a new instance of SetTabCookie.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bidi2pdf/bidi/commands/set_tab_cookie.rb', line 19

def initialize(name:,
               value:,
               domain:,
               browsing_context_id:,
               path: "/",
               secure: true,
               http_only: false,
               same_site: "strict",
               ttl: 30)
  @name = name
  @value = value
  @domain = domain
  @path = path
  @secure = secure
  @http_only = http_only
  @same_site = same_site
  @ttl = ttl
  @browsing_context_id = browsing_context_id
end

Class Attribute Details

.time_providerObject



12
13
14
# File 'lib/bidi2pdf/bidi/commands/set_tab_cookie.rb', line 12

def time_provider
  @time_provider ||= -> { Time.now }
end

Instance Attribute Details

#browsing_context_idObject (readonly)

Returns the value of attribute browsing_context_id.



17
18
19
# File 'lib/bidi2pdf/bidi/commands/set_tab_cookie.rb', line 17

def browsing_context_id
  @browsing_context_id
end

#domainObject (readonly)

Returns the value of attribute domain.



17
18
19
# File 'lib/bidi2pdf/bidi/commands/set_tab_cookie.rb', line 17

def domain
  @domain
end

#http_onlyObject (readonly)

Returns the value of attribute http_only.



17
18
19
# File 'lib/bidi2pdf/bidi/commands/set_tab_cookie.rb', line 17

def http_only
  @http_only
end

#nameObject (readonly)

Returns the value of attribute name.



17
18
19
# File 'lib/bidi2pdf/bidi/commands/set_tab_cookie.rb', line 17

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



17
18
19
# File 'lib/bidi2pdf/bidi/commands/set_tab_cookie.rb', line 17

def path
  @path
end

#same_siteObject (readonly)

Returns the value of attribute same_site.



17
18
19
# File 'lib/bidi2pdf/bidi/commands/set_tab_cookie.rb', line 17

def same_site
  @same_site
end

#secureObject (readonly)

Returns the value of attribute secure.



17
18
19
# File 'lib/bidi2pdf/bidi/commands/set_tab_cookie.rb', line 17

def secure
  @secure
end

#ttlObject (readonly)

Returns the value of attribute ttl.



17
18
19
# File 'lib/bidi2pdf/bidi/commands/set_tab_cookie.rb', line 17

def ttl
  @ttl
end

#valueObject (readonly)

Returns the value of attribute value.



17
18
19
# File 'lib/bidi2pdf/bidi/commands/set_tab_cookie.rb', line 17

def value
  @value
end

Instance Method Details

#expiryObject



39
40
41
# File 'lib/bidi2pdf/bidi/commands/set_tab_cookie.rb', line 39

def expiry
  self.class.time_provider.call.to_i + ttl
end

#method_nameObject



43
44
45
# File 'lib/bidi2pdf/bidi/commands/set_tab_cookie.rb', line 43

def method_name
  "storage.setCookie"
end

#paramsObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/bidi2pdf/bidi/commands/set_tab_cookie.rb', line 47

def params
  {
    cookie: {
      name: name,
      value: {
        type: "string",
        value: value
      },
      domain: domain,
      path: path,
      secure: secure,
      httpOnly: http_only,
      sameSite: same_site,
      expiry: expiry
    },
    partition: {
      type: "context",
      context: browsing_context_id
    }
  }.compact
end