Class: Epages::ImageSize

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/epages/image_size.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

build_shop_from, camelize_keys, camelize_words, options_to_multipart_request, options_to_patch_request, parse_attribute_as, parse_attribute_as_array_of, parse_attributes, symbolize_keys!, to_query_options, underscorize_keys

Constructor Details

#initialize(data) ⇒ ImageSize

Returns a new instance of ImageSize.



9
10
11
12
# File 'lib/epages/image_size.rb', line 9

def initialize(data)
  parse_attribute_as_array_of(:images, data.delete(:sizes), Epages::Image)
  parse_attributes(data)
end

Instance Attribute Details

#imagesObject

Returns the value of attribute images.



7
8
9
# File 'lib/epages/image_size.rb', line 7

def images
  @images
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/epages/image_size.rb', line 7

def name
  @name
end

Instance Method Details

#lengthObject

return the length of the slideshow



28
29
30
# File 'lib/epages/image_size.rb', line 28

def length
  images.size
end

return the link of image with the indicated size

Parameters:

  • size (String)

    . The name of the image classifier



22
23
24
25
# File 'lib/epages/image_size.rb', line 22

def size_link(size)
  link = images.find { |i| i.classifier == size }
  link ? link.url : nil
end

#sizesObject

return a sorted array with the name of all available sizes



15
16
17
# File 'lib/epages/image_size.rb', line 15

def sizes
  images.collect(&:classifier).sort
end