Class: Slk::Models::Workspace

Inherits:
Data
  • Object
show all
Defined in:
lib/slk/models/workspace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, token:, cookie: nil) ⇒ Workspace

Returns a new instance of Workspace.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/slk/models/workspace.rb', line 9

def initialize(name:, token:, cookie: nil)
  name_str = name.to_s.strip
  token_str = token.to_s
  cookie_str = cookie&.to_s

  validate_name!(name_str)
  validate_token!(token_str)
  validate_cookie!(token_str, cookie_str)

  super(name: name_str.freeze, token: token_str.freeze, cookie: cookie_str&.freeze)
end

Instance Attribute Details

Returns the value of attribute cookie

Returns:

  • (Object)

    the current value of cookie



8
9
10
# File 'lib/slk/models/workspace.rb', line 8

def cookie
  @cookie
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



8
9
10
# File 'lib/slk/models/workspace.rb', line 8

def name
  @name
end

#tokenObject (readonly)

Returns the value of attribute token

Returns:

  • (Object)

    the current value of token



8
9
10
# File 'lib/slk/models/workspace.rb', line 8

def token
  @token
end

Instance Method Details

#headersObject



27
28
29
30
31
# File 'lib/slk/models/workspace.rb', line 27

def headers
  h = { 'Authorization' => "Bearer #{token}", 'Content-Type' => 'application/json; charset=utf-8' }
  h['Cookie'] = "d=#{cookie}" if cookie
  h
end

#to_sObject



25
# File 'lib/slk/models/workspace.rb', line 25

def to_s = name

#xoxb?Boolean

Returns:

  • (Boolean)


22
# File 'lib/slk/models/workspace.rb', line 22

def xoxb? = token.start_with?('xoxb-')

#xoxc?Boolean

Returns:

  • (Boolean)


21
# File 'lib/slk/models/workspace.rb', line 21

def xoxc? = token.start_with?('xoxc-')

#xoxp?Boolean

Returns:

  • (Boolean)


23
# File 'lib/slk/models/workspace.rb', line 23

def xoxp? = token.start_with?('xoxp-')