Last active
August 29, 2015 14:24
-
-
Save JeffCohen/742a4628045c453b83de to your computer and use it in GitHub Desktop.
product.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product | |
attr_accessor :title | |
attr_accessor :image_url | |
attr_accessor :url | |
def initialize(title, image_slug, asin) | |
@title = title | |
@url = "http://www.amazon.com/dp/#{asin}" | |
@image_url = "http://ecx.images-amazon.com/images/I/#{image_slug}._SL1500_.jpg" | |
end | |
def self.all | |
data = [ | |
["TDK A12 TREK Wireless Outdoor Speaker", "816rAOJX-GL", "B00IOIJD5I"], | |
["Fitbit Flex Wireless Activity + Sleep Wristband, Slate", "51qrk3-c-lL", "B00BGO0QE"], | |
["GoPro HERO4 BLACK 4K Action Camera", "71X7ZijN3yL", "B00NIYNUF2"], | |
["Epiphone DR-100 Acoustic Guitar, Natural","71RMP9v4NQL", "B0002D02IU"], | |
["Google Chromecast HDMI Streaming Media Player", "811nvG%2BLgML", "B00DR0PDNE"] | |
] | |
products = data.map do |info| | |
Product.new(info[0], info[1], info[2]) | |
end | |
return products | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment