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 image url
Array of additional items
Integer angle of the image
String background color of image
String color of image
ext
Integer file size
String focus of the image
String gender of the image
String hash of the image
instance of AboutYou::SDK::Model::ImageSize
Integer mime type of the image
Hash model data
Integer next detail level
String preparation
Integer type
String View
Public Class Methods
This method is used for creating an instance of this class by a json_object.
-
Args :
-
json_object
-> the json_object received from the api
-
-
Returns :
-
Instance of
AboutYou::SDK::Model::Image
-
# 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
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