Sha256: 0bed6360e274f28b5c912dd0fb3d0fb5568bce022d52844a17f19b84a27eb06d

Contents?: true

Size: 751 Bytes

Versions: 5

Compression:

Stored size: 751 Bytes

Contents

require "pstore"

module Wurfl; end

=begin
A simple module to hold commonly used methods for the WURFL.
This is currently just loading and saving a WURFL PStore database.
=end
module Wurfl::Utils

  # Does not catch exception, but throws to the caller.  
  def load_wurfl_pstore(pstorefile)
    pstore = PStore.new(pstorefile)
    handsets = fallbacks = nil
    pstore.transaction do |ps|
      handsets = ps["handsets"]
      fallbacks = ps["fallback"]
    end      
    return handsets,fallbacks
  end

  #Also throws exceptions to the caller.
  def save_wurfl_pstore(pstorefile,handsets,fallbacks)
    store = PStore.new(pstorefile)
    store.transaction do |ps|
      ps["handsets"] = handsets
      ps["fallback"] = fallbacks
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wurfl-1.1.1 lib/wurfl/utils.rb
wurfl-1.1.2 lib/wurfl/utils.rb
wurfl-1.2.0 lib/wurfl/utils.rb
wurfl-1.0.2 lib/wurfl/utils.rb
wurfl-1.1.0 lib/wurfl/utils.rb