Class: Opera::MobileStore::ProductImage
- Inherits:
-
Object
- Object
- Opera::MobileStore::ProductImage
- Includes:
- ActiveModel::Model, ActiveModel::Serialization, InspectableAttributes
- Defined in:
- lib/opera/mobile_store/product_image.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
All attributes are Read-Only…
-
#type ⇒ Object
All attributes are Read-Only…
-
#url ⇒ Object
All attributes are Read-Only…
-
#width ⇒ Object
All attributes are Read-Only…
Class Method Summary collapse
Instance Method Summary collapse
Methods included from InspectableAttributes
Instance Attribute Details
#height ⇒ Object
All attributes are Read-Only…
12 13 14 |
# File 'lib/opera/mobile_store/product_image.rb', line 12 def height @height end |
#type ⇒ Object
All attributes are Read-Only…
12 13 14 |
# File 'lib/opera/mobile_store/product_image.rb', line 12 def type @type end |
#url ⇒ Object
All attributes are Read-Only…
12 13 14 |
# File 'lib/opera/mobile_store/product_image.rb', line 12 def url @url end |
#width ⇒ Object
All attributes are Read-Only…
12 13 14 |
# File 'lib/opera/mobile_store/product_image.rb', line 12 def width @width end |
Class Method Details
.build_from_nokogiri_node(node) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/opera/mobile_store/product_image.rb', line 22 def self.build_from_nokogiri_node(node) data = { type: node.name, url: node.text.strip } # Extract width + height data: width = node.xpath("string(@width)") height = node.xpath("string(@height)") data[:width] = width.to_i if width.present? data[:height] = width.to_i if height.present? self.new data end |
Instance Method Details
#attributes ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/opera/mobile_store/product_image.rb', line 14 def attributes [:type, :width, :height, :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 |