Class: ShipEngine::Utils::UserAgent

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

Overview

Class responsible for managing the user agent.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version = VERSION, platform = RUBY_PLATFORM) ⇒ UserAgent

Returns a new instance of UserAgent.

Raises:

  • (::StandardError)


11
12
13
14
15
16
17
# File 'lib/shipengine/utils/user_agent.rb', line 11

def initialize(version = VERSION, platform = RUBY_PLATFORM)
  raise ::StandardError, 'Cannot get version' unless version
  raise ::StandardError, 'Cannot get platform' unless platform

  @version = version
  @platform = platform
end

Instance Attribute Details

#platformObject (readonly)

Returns the value of attribute platform.



9
10
11
# File 'lib/shipengine/utils/user_agent.rb', line 9

def platform
  @platform
end

#versionObject (readonly)

Returns the value of attribute version.



9
10
11
# File 'lib/shipengine/utils/user_agent.rb', line 9

def version
  @version
end

Instance Method Details

#to_sObject



19
20
21
# File 'lib/shipengine/utils/user_agent.rb', line 19

def to_s
  "shipengine-ruby/#{@version} (#{@platform})"
end