Class: Amazon::Associates::Image

Inherits:
ApiResult show all
Defined in:
lib/amazon-associates/types/image.rb

Instance Method Summary collapse

Constructor Details

#initialize(url = nil, width = nil, height = nil) ⇒ Image

Returns a new instance of Image.



8
9
10
11
12
# File 'lib/amazon-associates/types/image.rb', line 8

def initialize(url = nil, width = nil, height = nil)
  @url = url
  @width = to_measurement(width)
  @height = to_measurement(height)
end

Instance Method Details

#==(other) ⇒ Object



14
15
16
17
# File 'lib/amazon-associates/types/image.rb', line 14

def ==(other)
  return nil unless other.is_a? Image
  url == other.url and width == other.width and height == other.height
end

#inspectObject



27
28
29
# File 'lib/amazon-associates/types/image.rb', line 27

def inspect
  "#<#{self.class}: #{url},#{width}x#{height}>"
end

#sizeObject



19
20
21
22
23
24
25
# File 'lib/amazon-associates/types/image.rb', line 19

def size
  unless height.units == 'pixels' and width.units == 'pixels'
    raise 'size not available for images not denominated in pixels'
  end

  "#{width.value.round}x#{height.value.round}"
end