Class: KcoRuby::UserAgent
- Inherits:
-
Object
- Object
- KcoRuby::UserAgent
- Includes:
- Sys
- Defined in:
- lib/kco_ruby/user_agent.rb
Overview
Responsible for creating User agent strings
Instance Method Summary collapse
- #add_field(field) ⇒ Object
-
#initialize ⇒ UserAgent
constructor
A new instance of UserAgent.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ UserAgent
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_s ⇒ Object
22 23 24 |
# File 'lib/kco_ruby/user_agent.rb', line 22 def to_s @fields.map { |field| field.to_s }.join(" ") end |