class Opera::MobileStore::Build
Attributes
billing[RW]
All attributes are Read-Only…
build_update_date[RW]
All attributes are Read-Only…
files[RW]
All attributes are Read-Only…
id[RW]
All attributes are Read-Only…
installer_type[RW]
All attributes are Read-Only…
languages[RW]
All attributes are Read-Only…
locales[RW]
All attributes are Read-Only…
name[RW]
All attributes are Read-Only…
package_name[RW]
All attributes are Read-Only…
platform[RW]
All attributes are Read-Only…
supported_screens[RW]
All attributes are Read-Only…
type[RW]
All attributes are Read-Only…
used_permissions[RW]
All attributes are Read-Only…
uses_sdk[RW]
All attributes are Read-Only…
version_code[RW]
All attributes are Read-Only…
version_name[RW]
All attributes are Read-Only…
Public Class Methods
build_from_nokogiri_node(node)
click to toggle source
# File lib/opera/mobile_store/build.rb, line 113 def self.build_from_nokogiri_node(node) version_code = node.xpath("string(version_code)") data = { id: node.xpath("string(@id)").to_i, name: node.xpath("string(name)").strip, platform: node.xpath("string(platform)").strip, type: node.xpath("string(type)").strip, installer_type: node.xpath("string(installer_type)").strip, package_name: node.xpath("string(package_name)").strip, version_name: node.xpath("string(version_name)").strip, version_code: version_code.present? ? version_code.to_i : nil, build_update_date: Time.parse(node.xpath "string(build_update_date)"), files: node.xpath("files/file").map do |f| BuildFile.build_from_nokogiri_node f end, languages: node.xpath("languages/language").map do |language| language.attributes["code"].to_s.strip end, supported_screens: node.xpath("supports_screens/screen").map do |scr| scr.text.strip end, used_permissions: node.xpath("uses_permissions/permission").map do |per| per.text.strip end, locales: node.xpath("locales/locale").map do |locale_node| locale_node.text.strip end }.select { |key, val| val.present? } data[:billing] = node.xpath("string(billing)").to_i > 0 uses_sdk_node = node.xpath("uses_sdk").first if uses_sdk_node.present? uses_sdk_attributes = { min: uses_sdk_node.xpath("string(@min)").strip, target: uses_sdk_node.xpath("string(@target)").strip, max: uses_sdk_node.xpath("string(@max)").strip }.select { |k,v| v.present? }.inject({}) do |hsh, keyval| key, val = keyval hsh[key] = val.to_i hsh end data[:uses_sdk] = UsesSDK.new uses_sdk_attributes end self.new data end
deserialize(serializable_hash)
click to toggle source
# File lib/opera/mobile_store/build.rb, line 95 def self.deserialize(serializable_hash) attributes_hash = serializable_hash.inject({}) do |hsh, keyval| field_name, field_value = keyval case field_name when 'files' field_value = field_value.map do |item_serializable_hash| BuildFile.deserialize item_serializable_hash end end hsh[field_name] = field_value hsh end self.new attributes_hash end
Public Instance Methods
attributes()
click to toggle source
# File lib/opera/mobile_store/build.rb, line 64 def attributes [ :id, :name, :platform, :type, :installer_type, :package_name, :version_name, :version_code, :build_update_date, :files, :billing, :languages, :uses_sdk, :supported_screens, :used_permissions, :locales ].inject({}) do |hash, field_name| field_value = self.public_send field_name hash[field_name.to_s] = field_value if field_value.present? hash end end
compatibility()
click to toggle source
# File lib/opera/mobile_store/build.rb, line 43 def compatibility @compatibility ||= begin compat_query = Opera::MobileStore::Compatibility.where(build_id: id) compat = compat_query.first if uses_sdk.present? compat.min_sdk_version = uses_sdk.min compat.max_sdk_version = uses_sdk.max compat.target_sdk_version = uses_sdk.target end compat end if id.present? end
min_sdk_version()
click to toggle source
# File lib/opera/mobile_store/build.rb, line 56 def min_sdk_version @min_sdk_version ||= if uses_sdk.present? uses_sdk.min else compatibility.min_sdk_version end end
serializable_hash(options = nil)
click to toggle source
Override of serializable_hash
:
This override will prevent dumping special objects to the hash:
# File lib/opera/mobile_store/build.rb, line 79 def serializable_hash(options = nil) attributes.inject({}) do |shsh, keyval| field_name, field_value = keyval case field_name when 'uses_sdk' field_value = field_value.serializable_hash when 'files' # Array of special objects field_value = field_value.map(&:serializable_hash) end shsh[field_name] = field_value shsh end end