Class: Spaceship::Tunes::Availability
- Defined in:
- spaceship/lib/spaceship/tunes/availability.rb
Instance Attribute Summary collapse
-
#app_available_date ⇒ String
App available date in format of “YYYY-MM-DD”.
-
#cleared_for_preorder ⇒ Bool
Cleared for preorder.
-
#include_future_territories ⇒ Bool
Are future territories included?.
-
#territories ⇒ Array of Spaceship::Tunes::Territory objects
A list of the territories.
Attributes inherited from Base
Class Method Summary collapse
-
.from_territories(territories = [], params = {}) ⇒ Object
Create a new object based on a set of territories.
Methods inherited from TunesBase
Methods inherited from Base
attr_accessor, attr_mapping, attributes, #attributes, factory, #initialize, #inspect, mapping_module, method_missing, set_client, #setup, #to_s
Constructor Details
This class inherits a constructor from Spaceship::Base
Instance Attribute Details
#app_available_date ⇒ String
Returns App available date in format of “YYYY-MM-DD”.
16 17 18 |
# File 'spaceship/lib/spaceship/tunes/availability.rb', line 16 def app_available_date @app_available_date end |
#cleared_for_preorder ⇒ Bool
Returns Cleared for preorder.
13 14 15 |
# File 'spaceship/lib/spaceship/tunes/availability.rb', line 13 def cleared_for_preorder @cleared_for_preorder end |
#include_future_territories ⇒ Bool
Returns Are future territories included?.
7 8 9 |
# File 'spaceship/lib/spaceship/tunes/availability.rb', line 7 def include_future_territories @include_future_territories end |
#territories ⇒ Array of Spaceship::Tunes::Territory objects
Returns A list of the territories.
10 11 12 |
# File 'spaceship/lib/spaceship/tunes/availability.rb', line 10 def territories @territories end |
Class Method Details
.from_territories(territories = [], params = {}) ⇒ Object
Create a new object based on a set of territories.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'spaceship/lib/spaceship/tunes/availability.rb', line 27 def self.from_territories(territories = [], params = {}) # Initializes the DataHash with our preOrder structure so values # that are being modified will be saved # # Note: A better solution for this in the future might be to improve how # Base::DataHash sets values for paths that don't exist obj = self.new( 'preOrder' => { 'clearedForPreOrder' => { 'value' => false }, 'appAvailableDate' => { 'value' => nil } } ) # Detect if the territories attribute is an array of Strings and convert to Territories obj.territories = if territories[0].kind_of?(String) territories.map { |territory| Spaceship::Tunes::Territory.from_code(territory) } else territories end obj.include_future_territories = params.fetch(:include_future_territories, true) obj.cleared_for_preorder = params.fetch(:cleared_for_preorder, false) obj.app_available_date = params.fetch(:app_available_date, nil) return obj end |