class AboutYou::SDK::Model::Image

This class is a represenatation of an Image model

Constants

MAX_HEIGHT

max height of an image

MAX_WIDTH

max width of an image

MIN_HEIGHT

min height of an image

MIN_WIDTH

min width of an image

Attributes

base_url[RW]

base image url

additional_items[RW]

Array of additional items

angle[RW]

Integer angle of the image

background[RW]

String background color of image

color[RW]

String color of image

ext[RW]

ext

file_size[RW]

Integer file size

focus[RW]

String focus of the image

gender[RW]

String gender of the image

hash[RW]

String hash of the image

image_size[RW]
mime_type[RW]

Integer mime type of the image

model_data[RW]

Hash model data

next_detail_level[RW]

Integer next detail level

preparation[RW]

String preparation

tags[RW]

Array of String tags

type[RW]

Integer type

view[RW]

String View

Public Class Methods

create_from_json(json_object) click to toggle source

This method is used for creating an instance of this class by a json_object.

# File lib/AboutYou/Model/image.rb, line 65
def self.create_from_json(json_object)
  image = new

  image.additional_items  = json_object['additional_items'] ? json_object['additional_items'] : nil
  image.angle             = json_object['angle'] ? json_object['angle'] : nil
  image.background        = json_object['background'] ? json_object['background'] : nil
  image.color             = json_object['color'] ? json_object['color'] : nil
  image.ext               = json_object['ext'] ? json_object['ext'] : nil
  image.file_size         = json_object['size'] ? json_object['size'] : 0
  image.focus             = json_object['focus'] ? json_object['focus'] : nil
  image.gender            = json_object['gender'] ? json_object['gender'] : nil
  image.hash              = json_object['hash'] ? json_object['hash'] : nil
  image.mime_type         = json_object['mime'] ? json_object['mime'] : nil
  image.model_data        = json_object['model_data'] ? json_object['model_data'] : nil
  image.next_detail_level = json_object['next_detail_level'] ? json_object['next_detail_level'] : nil
  image.preparation       = json_object['preparation'] ? json_object['preparation'] : nil
  image.tags              = json_object['tags'] ? json_object['tags'] : nil
  image.type              = json_object['type'] ? json_object['type'] : nil
  image.view              = json_object['view'] ? json_object['view'] : nil

  image.image_size = ImageSize.new(
    Integer(json_object['image']['width']),
    Integer(json_object['image']['height'])
  )

  image
end

Public Instance Methods

url(width = 200, height = 200) click to toggle source

This method is used for getting the image url for image

  • Args :

    • width -> Width of the image

    • height -> Height of the image

  • Returns :

    • String url for the image

# File lib/AboutYou/Model/image.rb, line 103
def url(width = 200, height = 200)
  width = [[width, MAX_WIDTH].min, MIN_WIDTH].max
  height = [[height, MAX_HEIGHT].min, MIN_HEIGHT].max

  self.class.base_url + '/' + hash + '?width=' + String(width) +
    '&height=' + String(height)
end