Copyright © 2013 by mTLD Top Level Domain Limited. All rights reserved.
Portions copyright © 2008 by Argo Interactive Limited.
Portions copyright © 2008 by Nokia Inc.
Portions copyright © 2008 by Telecom Italia Mobile S.p.A.
Portions copyright © 2008 by Volantis Systems Limited.
Portions copyright © 2002-2008 by Andreas Staeding.
Portions copyright © 2008 by Zandan.
dotMobi
Class to provide methods and constants to handle properties.
The following public methods have been migrated from the v1.5.3 DeviceAtlas class:
getValue()
propertyFromId()
convertToTyped()
Public static constant.
Given a property type, it converts a property value to a typed object.
# File ../Src/propshandler.rb, line 63 def self.convertToTyped(propValue, type) case type when 's' return propValue.to_s when 'b' return (propValue.to_i == 1) when 'i' return propValue.to_i when 'd' return Date.parse(propValue) end end
Given a property Id, it converts a property value to a typed object.
# File ../Src/propshandler.rb, line 56 def self.convertToTypedByPropertyId(tree, propValue, propertyId) type = tree[ID_TO_PROPERTIES_WITH_TYPE][propertyId.to_i][0..0] convertToTyped(propValue, type) end
Gets the value for the property value id and either converts it to a strong type or returns a string.
# File ../Src/propshandler.rb, line 41 def self.getValue(tree, propId, propValId, typed = false) val = nil if typed # Return the property value as typed. obj = tree[ID_TO_VALUES][propValId] val = convertToTypedByPropertyId(tree, obj, propId) else # Return the value for a value's coded ID. val = tree[ID_TO_VALUES][propValId.to_i].to_s end val end
This function merges the properties that have been directly detected from the User-Agent with the main properties map from the JSON data file into one.
# File ../Src/propshandler.rb, line 30 def self.mergeProperties(properties, uaProperties) if properties && uaProperties uaProperties.each do |key,val| properties[key] = val end end end
Return the name for a property's coded ID.
# File ../Src/propshandler.rb, line 78 def self.propertyFromId(tree, id) string = tree[ID_TO_PROPERTIES_WITH_TYPE][id.to_i] return if string.nil? string[1..string.size] end