Class: Lipseys::Image

Inherits:
Base
  • Object
show all
Defined in:
lib/lipseys/image.rb

Constant Summary collapse

API_URL =
'https://www.lipseys.com/API/catalog.ashx'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Image

Returns a new instance of Image.



6
7
8
9
10
# File 'lib/lipseys/image.rb', line 6

def initialize(options = {})
  requires!(options, :username, :password)

  @options = options
end

Class Method Details

.urls(options = {}) ⇒ Object



12
13
14
# File 'lib/lipseys/image.rb', line 12

def self.urls(options = {})
  new(options).urls
end

Instance Method Details

#urls(options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/lipseys/image.rb', line 16

def urls(options = {})
  tempfile  = stream_to_tempfile(API_URL, @options)
  images    = Array.new

  Lipseys::Parser.parse(tempfile, 'Item') do |item|
    image = Hash.new
    image[:item_identifier] = content_for(item, 'ItemNo')
    image[:url] = "http://www.lipseys.net/images/#{content_for(item, 'Image')}"

    images.push(image)
  end

  images
end