Class: AssemblyAI::UserAgent

Inherits:
Object
  • Object
show all
Defined in:
lib/assemblyai/types/user_agent.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeUserAgent

Returns a new instance of UserAgent.



18
19
20
# File 'lib/assemblyai/types/user_agent.rb', line 18

def initialize
  @user_agent_items = {}
end

Instance Attribute Details

#user_agent_itemsObject (readonly)

Returns the value of attribute user_agent_items.



16
17
18
# File 'lib/assemblyai/types/user_agent.rb', line 16

def user_agent_items
  @user_agent_items
end

Class Method Details

.merge(user_agent1, user_agent2) ⇒ AssemblyAI::UserAgent

Parameters:

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/assemblyai/types/user_agent.rb', line 35

def self.merge(user_agent1, user_agent2)
  merged_user_agent = AssemblyAI::UserAgent.new

  user_agent1&.user_agent_items&.each do |key, item|
    merged_user_agent.add_item(key, item)
  end

  user_agent2&.user_agent_items&.each do |key, item|
    merged_user_agent.add_item(key, item)
  end

  merged_user_agent
end

Instance Method Details

#add_item(key, user_agent_item) ⇒ Object

Parameters:



24
25
26
27
28
29
30
# File 'lib/assemblyai/types/user_agent.rb', line 24

def add_item(key, user_agent_item)
  if user_agent_item.nil?
    @user_agent_items.delete(key)
  else
    @user_agent_items[key] = user_agent_item
  end
end

#serializeString

Returns:

  • (String)


50
51
52
53
54
55
56
# File 'lib/assemblyai/types/user_agent.rb', line 50

def serialize
  serialized_items = @user_agent_items.map do |key, item|
    "#{key}=#{item.name}/#{item.version}"
  end.join(" ")

  "AssemblyAI/1.0 (#{serialized_items})"
end