infuze ruby module user guide

WURFL InFuze Module for Ruby: User Guide

WURFL InFuze for Ruby is a Ruby module wrapping the WURFL C/C++ API and encapsulating it in an object oriented manner to provide a fast and intuitive interface. It is released for linux/macos platforms for ruby versions 1.9 or higher.

Installing libwurfl

IMPORTANT: Installing libwurfl

In order for the Module to work it is ESSENTIAL that the libwurfl library is installed on your system. libwurfl is provided in your Customer Vault/FileX.

If you have not already installed libwurfl, instructions can be found here. Release notes for each API can be found here.

Installation on Linux/MacOS X

InFuze for Ruby is available as a gem and requires the WURFL InFuze C/C++ API to be installed. If you have not already installed libwurfl, instructions can be found here. Release notes for each API can be found here. You will need ruby-dev and rubygems:

On debian based linux:

$ sudo apt-get install ruby-dev
$ sudo apt-get install rubygems

On redhat/centos:

$ sudo yum install ruby-devel
$ sudo yum install rubygems

Now install the gem:

$ sudo gem install --no-ri --no-rdoc wurfl-0.2.2.gem

Installation on Windows

The Ruby module has been tested with a RubyInstaller environment on Windows for installation instructions. On Windows, WURFL InFuze libs go to C:\Windows\System32.

Install the gem:

C:\> gem install --no-ri --no-rdoc wurfl-0.2.2.gem

Note: if you encounter any problem with RubyInstaller, please verify you correctly set up the environment variables.


Here is an example to get started using InFuze for Ruby:

require 'wurfl_obj'

# create Wurfl object
MyWurfl ="../resources/wurfl.xml", patches=[], high_accuracy=false, cache_provider=:WURFL_CACHE_PROVIDER_DOUBLE_LRU, cache_extra_config="10000,3000")

# Define a test User Agent
UserAgent = "Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/KRT16M) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/ Mobile Safari/537.36"

# Lookup a UserAgent string
    dev = MyWurfl.parse_useragent(UserAgent)
    rescue WurflError => err
        puts err.errorcode
        puts err.errormessage

# print deviceid
print("deviceid = " + dev.get_device_id() + "\n") # device ID

# print device capability
print("is_mobile = " + dev.get_capability("is_mobile") + "\n") # capability

# print virtual capability 
print("is_ios = " + dev.get_capability("is_ios") + "\n") # virtual capability

# get a set of capabilities
print(dev.get_capabilities(["brand_name", "model_name", "is_ios"]))

# Returns an array with a key-value dictionary
#[{:capability=>"brand_name", :value=>"Google"}, {:capability=>"model_name", :value=>"Nexus 5"}, {:capability=>"is_ios", :value=>"false"}]

# Get all capabilities

# Release the device object to avoid memory leaks


2017 ScientiaMobile Incorporated All Rights Reserved.

NOTICE: All information contained herein is, and remains the property of ScientiaMobile Incorporated and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to ScientiaMobile Incorporated and its suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from ScientiaMobile Incorporated.