Class: Algolia::UserAgent
- Inherits:
-
Object
- Object
- Algolia::UserAgent
- Defined in:
- lib/algolia/user_agent.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#add(segment, version = nil) ⇒ Object
Adds a segment to the UserAgent.
-
#initialize ⇒ UserAgent
constructor
A new instance of UserAgent.
Constructor Details
#initialize ⇒ UserAgent
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
#value ⇒ Object
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 |