Class: Opera::MobileStore::DeviceModel

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, ActiveModel::Serialization, InspectableAttributes, Opera::MobileStoreSDK::APIAccessible, Opera::MobileStoreSDK::IdentityMapable
Defined in:
lib/opera/mobile_store/device_model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Opera::MobileStoreSDK::IdentityMapable

#initialize

Methods included from InspectableAttributes

#inspect

Instance Attribute Details

#codeObject

All attributes are Read-Only…



16
17
18
# File 'lib/opera/mobile_store/device_model.rb', line 16

def code
  @code
end

#idObject

All attributes are Read-Only…



16
17
18
# File 'lib/opera/mobile_store/device_model.rb', line 16

def id
  @id
end

#nameObject

All attributes are Read-Only…



16
17
18
# File 'lib/opera/mobile_store/device_model.rb', line 16

def name
  @name
end

Class Method Details

.build_from_nokogiri_node(node) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/opera/mobile_store/device_model.rb', line 28

def self.build_from_nokogiri_node(node)
  data = {
    id:   node.xpath("number(@id)").to_i,
    code: node.xpath("string(@code)").strip,
    name: node.text.strip
  }.select { |key, val| val.present? }

  self.new data
end

Instance Method Details

#attributesObject



18
19
20
21
22
23
24
# File 'lib/opera/mobile_store/device_model.rb', line 18

def attributes
  [:id, :code, :name].inject({}) do |hash, field_name|
    field_value = self.public_send field_name
    hash[field_name.to_s] = field_value unless field_value.nil?
    hash
  end
end