Class: Arcp::Session::Hello

Inherits:
Data
  • Object
show all
Defined in:
lib/arcp/session/hello.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authObject (readonly)

Returns the value of attribute auth

Returns:

  • (Object)

    the current value of auth



5
6
7
# File 'lib/arcp/session/hello.rb', line 5

def auth
  @auth
end

#capabilitiesObject (readonly)

Returns the value of attribute capabilities

Returns:

  • (Object)

    the current value of capabilities



5
6
7
# File 'lib/arcp/session/hello.rb', line 5

def capabilities
  @capabilities
end

#client_nameObject (readonly)

Returns the value of attribute client_name

Returns:

  • (Object)

    the current value of client_name



5
6
7
# File 'lib/arcp/session/hello.rb', line 5

def client_name
  @client_name
end

#client_versionObject (readonly)

Returns the value of attribute client_version

Returns:

  • (Object)

    the current value of client_version



5
6
7
# File 'lib/arcp/session/hello.rb', line 5

def client_version
  @client_version
end

#resumeObject (readonly)

Returns the value of attribute resume

Returns:

  • (Object)

    the current value of resume



5
6
7
# File 'lib/arcp/session/hello.rb', line 5

def resume
  @resume
end

Class Method Details

.from_h(h) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/arcp/session/hello.rb', line 6

def self.from_h(h)
  h = h.transform_keys(&:to_s)
  caps = h['capabilities'] || {}
  new(
    client_name: h['client_name'],
    client_version: h['client_version'],
    auth: h['auth'] || {},
    capabilities: CapabilitySet.new(
      features: Array(caps['features']).freeze,
      encodings: Array(caps['encodings']).freeze,
      agents: nil
    ),
    resume: h['resume']
  )
end

Instance Method Details

#to_hObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/arcp/session/hello.rb', line 22

def to_h
  h = {
    'client_name' => client_name,
    'client_version' => client_version,
    'auth' => auth,
    'capabilities' => capabilities.to_h.except('agents')
  }
  h['resume'] = resume if resume
  h
end