class Opera::MobileStore::ProductImage
Attributes
height[RW]
All attributes are Read-Only…
type[RW]
All attributes are Read-Only…
url[RW]
All attributes are Read-Only…
width[RW]
All attributes are Read-Only…
Public Class Methods
build_from_nokogiri_node(node)
click to toggle source
# 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
Public Instance Methods
attributes()
click to toggle source
# 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