Class: Udger::UaParser
- Inherits:
-
BaseParser
- Object
- BaseParser
- Udger::UaParser
- Defined in:
- lib/udger/ua_parser.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
Returns the value of attribute db.
-
#object ⇒ Object
Returns the value of attribute object.
-
#ua_string ⇒ Object
Returns the value of attribute ua_string.
Instance Method Summary collapse
-
#initialize(db, ua_string, kargs = {}) ⇒ UaParser
constructor
A new instance of UaParser.
- #parse ⇒ Object
Constructor Details
#initialize(db, ua_string, kargs = {}) ⇒ UaParser
Returns a new instance of UaParser.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/udger/ua_parser.rb', line 5 def initialize(db, ua_string, kargs = {}) super(db) @match_crawler = kargs.fetch(:crawler, true) @match_client = kargs.fetch(:client, true) @match_os = kargs.fetch(:os, true) @match_device = kargs.fetch(:device, true) @match_device_market = kargs.fetch(:device_market, true) @ua_string = ua_string @object = UserAgent.new @os_id = 0 @client_id = 0 @client_class_id = -1 @deviceclass_id = 0 end |
Instance Attribute Details
#db ⇒ Object
Returns the value of attribute db.
3 4 5 |
# File 'lib/udger/ua_parser.rb', line 3 def db @db end |
#object ⇒ Object
Returns the value of attribute object.
3 4 5 |
# File 'lib/udger/ua_parser.rb', line 3 def object @object end |
#ua_string ⇒ Object
Returns the value of attribute ua_string.
3 4 5 |
# File 'lib/udger/ua_parser.rb', line 3 def ua_string @ua_string end |
Instance Method Details
#parse ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/udger/ua_parser.rb', line 22 def parse return unless ua_string object.ua_string = ua_string crawler_data = @match_crawler ? parse_crawler : [] if !crawler_data.empty? format_crawler_data crawler_data[0] else parse_client if @match_client if @match_os || @match_device_market parse_os parse_client_os end parse_device if @match_device devise_market_name if @match_device_market end end |