Class: Shutterstock::Image
Constant Summary
Constants inherited from Driver
Instance Attribute Summary collapse
-
#added ⇒ Object
readonly
Returns the value of attribute added.
-
#aspect ⇒ Object
readonly
Returns the value of attribute aspect.
-
#assets ⇒ Object
readonly
Returns the value of attribute assets.
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
-
#contributor ⇒ Object
readonly
Returns the value of attribute contributor.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#has_model_release ⇒ Object
readonly
Returns the value of attribute has_model_release.
-
#has_property_release ⇒ Object
readonly
Returns the value of attribute has_property_release.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#image_type ⇒ Object
readonly
Returns the value of attribute image_type.
-
#is_adult ⇒ Object
readonly
Returns the value of attribute is_adult.
-
#is_editorial ⇒ Object
readonly
Returns the value of attribute is_editorial.
-
#is_illustration ⇒ Object
readonly
Returns the value of attribute is_illustration.
-
#keywords ⇒ Object
readonly
Returns the value of attribute keywords.
-
#media_type ⇒ Object
readonly
Returns the value of attribute media_type.
-
#model_releases ⇒ Object
readonly
Returns the value of attribute model_releases.
-
#models ⇒ Object
readonly
Returns the value of attribute models.
Class Method Summary collapse
Instance Method Summary collapse
- #adult? ⇒ Boolean
-
#editorial? ⇒ Boolean
boolean readers.
-
#fill ⇒ Object
Fetch all details of this image.
- #find ⇒ Object
- #illustration? ⇒ Boolean
-
#initialize(params = {}) ⇒ Image
constructor
“added_date”:“2012-11-09”, “aspect”:1.5, “assets”:{“small_jpg”:{“display_name”:“Small”,“dpi”:72,“file_size”:88064,“format”:“jpg”,“height”:333,“is_licensable”:true,“width”:500, “medium_jpg”:“display_name”:“Med”,“dpi”:300,“file_size”:301056,“format”:“jpg”,“height”:667,“is_licensable”:true,“width”:1000, “huge_jpg”:“display_name”:“Huge”,“dpi”:300,“file_size”:2790400,“format”:“jpg”,“height”:3090,“is_licensable”:true,“width”:4635, “supersize_jpg”:“display_name”:“Super”,“dpi”:300,“file_size”:10112609,“format”:“jpg”,“height”:6180,“is_licensable”:false,“width”:9270, “huge_tiff”:“display_name”:“Huge”,“dpi”:300,“file_size”:42966450,“format”:“tiff”,“height”:3090,“is_licensable”:false,“width”:4635, “supersize_tiff”:“display_name”:“Super”,“dpi”:300,“file_size”:171865800,“format”:“tiff”,“height”:6180,“is_licensable”:false,“width”:9270, “preview”:src="https://image.shutterstock.com/display_pic_with_logo/1306729/118139110/stock-photo-adorable-labrador-puppy-playing-with-a-chew-toy-on-white-backdrop-118139110.jpg" />”,“width”:450, “small_thumb”:src="https://thumb1.shutterstock.com/thumb_small/1306729/118139110/stock-photo-adorable-labrador-puppy-playing-with-a-chew-toy-on-white-backdrop-118139110.jpg" />”,“width”:100, “large_thumb”:src="https://thumb1.shutterstock.com/thumb_large/1306729/118139110/stock-photo-adorable-labrador-puppy-playing-with-a-chew-toy-on-white-backdrop-118139110.jpg" />”,“width”:150 }, “categories”:, “contributor”:“id”:“1306729”, “description”:“Adorable Labrador Puppy Playing with a Chew Toy on White Backdrop”, “image_type”:“photo”, “is_adult”:false, “keywords”:[“animal”,“animal themes”,“backgrounds”,“cute”,“dog”,“domestic animals”,“friendship”,“full length”,“isolated”], “media_type”:“image”}.
-
#license(format: nil, size: nil) ⇒ Object
License current image with available subscription.
- #load_ivars(params) ⇒ Object
- #model_release? ⇒ Boolean
- #property_release? ⇒ Boolean
- #similar ⇒ Object
Methods inherited from Driver
api, client, #client, #json_true?, #methods, #respond_to, #to_date
Constructor Details
#initialize(params = {}) ⇒ Image
"added_date":"2012-11-09",
"aspect":1.5,
"assets":{"small_jpg":{"display_name":"Small","dpi":72,"file_size":88064,"format":"jpg","height":333,"is_licensable":true,"width":500,
"medium_jpg":"display_name":"Med","dpi":300,"file_size":301056,"format":"jpg","height":667,"is_licensable":true,"width":1000,
"huge_jpg":"display_name":"Huge","dpi":300,"file_size":2790400,"format":"jpg","height":3090,"is_licensable":true,"width":4635,
"supersize_jpg":"display_name":"Super","dpi":300,"file_size":10112609,"format":"jpg","height":6180,"is_licensable":false,"width":9270,
"huge_tiff":"display_name":"Huge","dpi":300,"file_size":42966450,"format":"tiff","height":3090,"is_licensable":false,"width":4635,
"supersize_tiff":"display_name":"Super","dpi":300,"file_size":171865800,"format":"tiff","height":6180,"is_licensable":false,"width":9270,
"preview":<a href="\"height\":300,\"url\":\"https://image.shutterstock.com/display_pic_with_logo/1306729/118139110/stock-photo-adorable-labrador-puppy-playing-with-a-chew-toy-on-white-backdrop-118139110.jpg\",\"width\":450" target="_parent" title=""height":300,"url":"https://image.shutterstock.com/display_pic_with_logo/1306729/118139110/stock-photo-adorable-labrador-puppy-playing-with-a-chew-toy-on-white-backdrop-118139110.jpg","width":450">"height":300,"url":"https://image.shutterstock.com/display_pic_with_logo/1306729/118139110/stock-photo-adorable-labrador-puppy-playing-with-a-chew-toy-on-white-backdrop-118139110.jpg","width":450</a>,
"small_thumb":<a href="\"height\":67,\"url\":\"https://thumb1.shutterstock.com/thumb_small/1306729/118139110/stock-photo-adorable-labrador-puppy-playing-with-a-chew-toy-on-white-backdrop-118139110.jpg\",\"width\":100" target="_parent" title=""height":67,"url":"https://thumb1.shutterstock.com/thumb_small/1306729/118139110/stock-photo-adorable-labrador-puppy-playing-with-a-chew-toy-on-white-backdrop-118139110.jpg","width":100">"height":67,"url":"https://thumb1.shutterstock.com/thumb_small/1306729/118139110/stock-photo-adorable-labrador-puppy-playing-with-a-chew-toy-on-white-backdrop-118139110.jpg","width":100</a>,
"large_thumb":<a href="\"height\":100,\"url\":\"https://thumb1.shutterstock.com/thumb_large/1306729/118139110/stock-photo-adorable-labrador-puppy-playing-with-a-chew-toy-on-white-backdrop-118139110.jpg\",\"width\":150" target="_parent" title=""height":100,"url":"https://thumb1.shutterstock.com/thumb_large/1306729/118139110/stock-photo-adorable-labrador-puppy-playing-with-a-chew-toy-on-white-backdrop-118139110.jpg","width":150">"height":100,"url":"https://thumb1.shutterstock.com/thumb_large/1306729/118139110/stock-photo-adorable-labrador-puppy-playing-with-a-chew-toy-on-white-backdrop-118139110.jpg","width":150</a>
},
"categories":["id":"1","name":"Animals/Wildlife","id":"20","name":"NOT-CATEGORIZED"],
"contributor":"id":"1306729",
"description":"Adorable Labrador Puppy Playing with a Chew Toy on White Backdrop",
"image_type":"photo",
"is_adult":false,
"keywords":["animal","animal themes","backgrounds","cute","dog","domestic animals","friendship","full length","isolated"],
"media_type":"image"}
30 31 32 |
# File 'lib/client/image.rb', line 30 def initialize(params = {}) load_ivars(params) end |
Instance Attribute Details
#added ⇒ Object (readonly)
Returns the value of attribute added.
3 4 5 |
# File 'lib/client/image.rb', line 3 def added @added end |
#aspect ⇒ Object (readonly)
Returns the value of attribute aspect.
3 4 5 |
# File 'lib/client/image.rb', line 3 def aspect @aspect end |
#assets ⇒ Object (readonly)
Returns the value of attribute assets.
3 4 5 |
# File 'lib/client/image.rb', line 3 def assets @assets end |
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
3 4 5 |
# File 'lib/client/image.rb', line 3 def categories @categories end |
#contributor ⇒ Object (readonly)
Returns the value of attribute contributor.
3 4 5 |
# File 'lib/client/image.rb', line 3 def contributor @contributor end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/client/image.rb', line 3 def description @description end |
#has_model_release ⇒ Object (readonly)
Returns the value of attribute has_model_release.
3 4 5 |
# File 'lib/client/image.rb', line 3 def has_model_release @has_model_release end |
#has_property_release ⇒ Object (readonly)
Returns the value of attribute has_property_release.
3 4 5 |
# File 'lib/client/image.rb', line 3 def has_property_release @has_property_release end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
3 4 5 |
# File 'lib/client/image.rb', line 3 def hash @hash end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/client/image.rb', line 3 def id @id end |
#image_type ⇒ Object (readonly)
Returns the value of attribute image_type.
3 4 5 |
# File 'lib/client/image.rb', line 3 def image_type @image_type end |
#is_adult ⇒ Object (readonly)
Returns the value of attribute is_adult.
3 4 5 |
# File 'lib/client/image.rb', line 3 def is_adult @is_adult end |
#is_editorial ⇒ Object (readonly)
Returns the value of attribute is_editorial.
3 4 5 |
# File 'lib/client/image.rb', line 3 def is_editorial @is_editorial end |
#is_illustration ⇒ Object (readonly)
Returns the value of attribute is_illustration.
3 4 5 |
# File 'lib/client/image.rb', line 3 def is_illustration @is_illustration end |
#keywords ⇒ Object (readonly)
Returns the value of attribute keywords.
3 4 5 |
# File 'lib/client/image.rb', line 3 def keywords @keywords end |
#media_type ⇒ Object (readonly)
Returns the value of attribute media_type.
3 4 5 |
# File 'lib/client/image.rb', line 3 def media_type @media_type end |
#model_releases ⇒ Object (readonly)
Returns the value of attribute model_releases.
3 4 5 |
# File 'lib/client/image.rb', line 3 def model_releases @model_releases end |
#models ⇒ Object (readonly)
Returns the value of attribute models.
3 4 5 |
# File 'lib/client/image.rb', line 3 def models @models end |
Class Method Details
.find(id) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/client/image.rb', line 78 def self.find(id) resp = client.request do |r| r.path "/v2/images/#{id}" r.method :get end self.new(resp.body) end |
.search(search) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/client/image.rb', line 102 def self.search(search) search_params = {} if search.kind_of? String search_params[:query] = search else search_params = search end resp = client.request do |r| r.path "/v2/images/search" r.method :get r.params search_params end Images.new(resp.body) end |
Instance Method Details
#adult? ⇒ Boolean
60 61 62 |
# File 'lib/client/image.rb', line 60 def adult? @is_adult end |
#editorial? ⇒ Boolean
boolean readers
56 57 58 |
# File 'lib/client/image.rb', line 56 def editorial? @is_editorial end |
#fill ⇒ Object
Fetch all details of this image
119 120 121 122 |
# File 'lib/client/image.rb', line 119 def fill load_ivars(find.hash) self end |
#find ⇒ Object
86 87 88 |
# File 'lib/client/image.rb', line 86 def find self.class.find(self.id) end |
#illustration? ⇒ Boolean
64 65 66 |
# File 'lib/client/image.rb', line 64 def illustration? @is_illustration end |
#license(format: nil, size: nil) ⇒ Object
License current image with available subscription
125 126 127 128 |
# File 'lib/client/image.rb', line 125 def license(format: nil, size: nil) sub = find_subscription_for_this_size(size) License.license(subscription_id: sub.id, image_id: self, format: format, size: size, editorial_acknowledgement: (editorial? ? true : nil)) end |
#load_ivars(params) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/client/image.rb', line 34 def load_ivars(params) @hash = params @id = params["id"].to_i @description = params["description"] @added = to_date(params["added_date"]) @media_type = params["media_type"] @contributor = Contributor.new(params["contributor"]) if params["contributor"] @aspect = params["aspect"] @image_type = params["image_type"] @is_editorial = json_true? params["is_editorial"] @is_adult = json_true? params["is_adult"] @is_illustration = json_true? params["is_illustration"] @has_model_release = json_true? params["has_model_release"] @has_property_release = json_true? params["has_property_release"] @model_releases = params["model_releases"] @categories = Categories.new(params["categories"]) if params["categories"] @keywords = params["keywords"] @assets = ImageAssets.new(params["assets"]) if params["assets"] @models = Models.new(params["models"]) if params["models"] end |
#model_release? ⇒ Boolean
68 69 70 |
# File 'lib/client/image.rb', line 68 def model_release? @has_model_release end |
#property_release? ⇒ Boolean
72 73 74 |
# File 'lib/client/image.rb', line 72 def property_release? @has_property_release end |
#similar ⇒ Object
98 99 100 |
# File 'lib/client/image.rb', line 98 def similar @images = self.class.similar(self.id) end |