Class: Algolia::UserAgent

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeUserAgent

Returns a new instance of UserAgent.



5
6
7
# File 'lib/algolia/user_agent.rb', line 5

def initialize
  @value = "Algolia for Ruby (#{VERSION}); Ruby (#{RUBY_VERSION})"
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/algolia/user_agent.rb', line 3

def value
  @value
end

Instance Method Details

#add(segment, version = nil) ⇒ Object

Adds a segment to the UserAgent



11
12
13
14
15
16
17
18
19
# File 'lib/algolia/user_agent.rb', line 11

def add(segment, version = nil)
  if version.nil?
    @value += format("; %<segment>s", segment: segment)
  else
    @value += format("; %<segment>s (%<version>s)", segment: segment, version: version)
  end

  self
end