Class: Shutterstock::Subscriptions
- Inherits:
-
Array
- Object
- Array
- Shutterstock::Subscriptions
- Defined in:
- lib/client/subscriptions.rb
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
-
#search_id ⇒ Object
readonly
Returns the value of attribute search_id.
-
#sort_method ⇒ Object
readonly
Returns the value of attribute sort_method.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
Instance Method Summary collapse
- #active ⇒ Object
- #downloads_left ⇒ Object
- #expired ⇒ Object
- #find_subscription_for_image_size(size = nil) ⇒ Object
-
#initialize(raw_data) ⇒ Subscriptions
constructor
A new instance of Subscriptions.
Constructor Details
#initialize(raw_data) ⇒ Subscriptions
Returns a new instance of Subscriptions.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/client/subscriptions.rb', line 4 def initialize(raw_data) @raw_data = raw_data if raw_data.kind_of? Hash super(@raw_data["data"].map{ |subscription| Subscription.new(subscription) }) @total_count = raw_data["total_count"].to_i @page = raw_data["page"].to_i elsif raw_data.kind_of? Array super( @raw_data.map{ |subscription| Subscription.new(subscription) } ) end self end |
Instance Attribute Details
#page ⇒ Object (readonly)
Returns the value of attribute page.
3 4 5 |
# File 'lib/client/subscriptions.rb', line 3 def page @page end |
#raw_data ⇒ Object (readonly)
Returns the value of attribute raw_data.
3 4 5 |
# File 'lib/client/subscriptions.rb', line 3 def raw_data @raw_data end |
#search_id ⇒ Object (readonly)
Returns the value of attribute search_id.
3 4 5 |
# File 'lib/client/subscriptions.rb', line 3 def search_id @search_id end |
#sort_method ⇒ Object (readonly)
Returns the value of attribute sort_method.
3 4 5 |
# File 'lib/client/subscriptions.rb', line 3 def sort_method @sort_method end |
#total_count ⇒ Object (readonly)
Returns the value of attribute total_count.
3 4 5 |
# File 'lib/client/subscriptions.rb', line 3 def total_count @total_count end |
Instance Method Details
#active ⇒ Object
32 33 34 |
# File 'lib/client/subscriptions.rb', line 32 def active self.reject{|sub| sub.expired?} end |
#downloads_left ⇒ Object
24 25 26 |
# File 'lib/client/subscriptions.rb', line 24 def downloads_left self.select{|sub| sub.has_downloads_left?} end |
#expired ⇒ Object
28 29 30 |
# File 'lib/client/subscriptions.rb', line 28 def expired self.select{|sub| sub.expired?} end |
#find_subscription_for_image_size(size = nil) ⇒ Object
19 20 21 22 |
# File 'lib/client/subscriptions.rb', line 19 def find_subscription_for_image_size(size = nil) size = "huge" if !size self.active.select{|sub| sub.has_downloads_left? && sub.allows_image_size_download?(size)}.first end |