Class: KcoRuby::UserAgent

Inherits:
Object
  • Object
show all
Includes:
Sys
Defined in:
lib/kco_ruby/user_agent.rb

Overview

Responsible for creating User agent strings

Instance Method Summary collapse

Constructor Details

#initializeUserAgent

Returns a new instance of UserAgent.



10
11
12
13
14
15
16
# File 'lib/kco_ruby/user_agent.rb', line 10

def initialize
  # Components of the user-agent
  @fields = []
  add_field(UserAgentField.new('Library', "Significantbit.KCO.ApiWrapper", KcoRuby::VERSION))
  add_field(UserAgentField.new('OS', Uname.sysname, RUBY_PLATFORM))
  add_field(UserAgentField.new('Language', "Ruby", RUBY_VERSION))
end

Instance Method Details

#add_field(field) ⇒ Object



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

def add_field(field)
  @fields << field
end

#to_sObject



22
23
24
# File 'lib/kco_ruby/user_agent.rb', line 22

def to_s
  @fields.map { |field| field.to_s }.join(" ")
end