Class: Opera::MobileStore::BuildFile

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, ActiveModel::Serialization, InspectableAttributes
Defined in:
lib/opera/mobile_store/build_file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from InspectableAttributes

#inspect

Instance Attribute Details

#sizeObject

All attributes are Read-Only…



11
12
13
# File 'lib/opera/mobile_store/build_file.rb', line 11

def size
  @size
end

#urlObject

All attributes are Read-Only…



11
12
13
# File 'lib/opera/mobile_store/build_file.rb', line 11

def url
  @url
end

Class Method Details

.build_from_nokogiri_node(node) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/opera/mobile_store/build_file.rb', line 21

def self.build_from_nokogiri_node(node)

  data = { url: node.text.strip }

  # Extract width + height data:
  file_size = node.xpath("string(@size)")
  data[:size] = file_size.to_i if file_size.present?

  self.new data
end

Instance Method Details

#attributesObject



13
14
15
16
17
18
19
# File 'lib/opera/mobile_store/build_file.rb', line 13

def attributes
  [:size, :url].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