Class: Shutterstock::Subscription
- Defined in:
- lib/client/subscription.rb
Constant Summary
Constants inherited from Driver
Instance Attribute Summary collapse
-
#allotment ⇒ Object
readonly
Returns the value of attribute allotment.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#expiration_time ⇒ Object
readonly
Returns the value of attribute expiration_time.
-
#formats ⇒ Object
readonly
Returns the value of attribute formats.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#license ⇒ Object
readonly
Returns the value of attribute license.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#price_per_download ⇒ Object
readonly
Returns the value of attribute price_per_download.
Instance Method Summary collapse
-
#allows_image_size_download?(size) ⇒ Boolean
True if this subscription can handle the size passed eg “small”.
- #expired? ⇒ Boolean
- #has_downloads_left? ⇒ Boolean
-
#initialize(params = {}) ⇒ Subscription
constructor
A new instance of Subscription.
Methods inherited from Driver
api, client, #client, #json_true?, #methods, #respond_to, #to_date
Constructor Details
#initialize(params = {}) ⇒ Subscription
Returns a new instance of Subscription.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/client/subscription.rb', line 9 def initialize(params={}) @hash = params @id = params["id"] # (string), @description = params["description"] if params["description"] # (string, optional), @expiration_time = to_date params["expiration_time"] if params["expiration_time"] # (string, optional), @price_per_download = SubscriptionPrice.new(params["price_per_download"]) if params["price_per_download"] # (Price, optional), @license = params["license"] if params["license"] # (string, optional), @allotment = SubscriptionAllotment.new(params["allotment"]) if params["allotment"] # (Allotment, optional), @formats = SubscriptionLicenseFormats.new(params["formats"]) if params["formats"] # (LicenseFormat[], optional), @metadata = params["metadata"] if params["metadata"] # (SubscriptionMetadata, optional) end |
Instance Attribute Details
#allotment ⇒ Object (readonly)
Returns the value of attribute allotment.
5 6 7 |
# File 'lib/client/subscription.rb', line 5 def allotment @allotment end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/client/subscription.rb', line 5 def description @description end |
#expiration_time ⇒ Object (readonly)
Returns the value of attribute expiration_time.
5 6 7 |
# File 'lib/client/subscription.rb', line 5 def expiration_time @expiration_time end |
#formats ⇒ Object (readonly)
Returns the value of attribute formats.
5 6 7 |
# File 'lib/client/subscription.rb', line 5 def formats @formats end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/client/subscription.rb', line 5 def id @id end |
#license ⇒ Object (readonly)
Returns the value of attribute license.
5 6 7 |
# File 'lib/client/subscription.rb', line 5 def license @license end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/client/subscription.rb', line 5 def @metadata end |
#price_per_download ⇒ Object (readonly)
Returns the value of attribute price_per_download.
5 6 7 |
# File 'lib/client/subscription.rb', line 5 def price_per_download @price_per_download end |
Instance Method Details
#allows_image_size_download?(size) ⇒ Boolean
True if this subscription can handle the size passed eg “small”
26 27 28 |
# File 'lib/client/subscription.rb', line 26 def allows_image_size_download?(size) !!(!expired? && formats.find {|format| format.size == size}) end |
#expired? ⇒ Boolean
21 22 23 |
# File 'lib/client/subscription.rb', line 21 def expired? @expiration_time<DateTime.now end |
#has_downloads_left? ⇒ Boolean
30 31 32 |
# File 'lib/client/subscription.rb', line 30 def has_downloads_left? allotment && allotment.has_downloads_left? end |