Class: Arcp::Session::CapabilitySet

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

Constant Summary collapse

DEFAULT_ENCODINGS =
%w[utf8 base64].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#agentsObject (readonly)

Returns the value of attribute agents

Returns:

  • (Object)

    the current value of agents



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

def agents
  @agents
end

#encodingsObject (readonly)

Returns the value of attribute encodings

Returns:

  • (Object)

    the current value of encodings



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

def encodings
  @encodings
end

#featuresObject (readonly)

Returns the value of attribute features

Returns:

  • (Object)

    the current value of features



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

def features
  @features
end

Class Method Details

.local(features: Feature::ALL, encodings: DEFAULT_ENCODINGS, agents: nil) ⇒ Object



8
9
10
# File 'lib/arcp/session/capability_set.rb', line 8

def self.local(features: Feature::ALL, encodings: DEFAULT_ENCODINGS, agents: nil)
  new(features: features.dup.freeze, encodings: encodings.dup.freeze, agents: agents)
end

Instance Method Details

#intersect(other) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/arcp/session/capability_set.rb', line 12

def intersect(other)
  self.class.new(
    features: (features & other.features).freeze,
    encodings: (encodings & other.encodings).freeze,
    agents: other.agents || agents
  )
end

#supports?(feature) ⇒ Boolean

Returns:

  • (Boolean)


20
# File 'lib/arcp/session/capability_set.rb', line 20

def supports?(feature) = features.include?(feature)

#to_hObject



22
23
24
25
26
# File 'lib/arcp/session/capability_set.rb', line 22

def to_h
  h = { 'features' => features, 'encodings' => encodings }
  h['agents'] = agents.to_a if agents
  h
end