Class: Spaceship::Tunes::PricingTier

Inherits:
TunesBase show all
Defined in:
lib/spaceship/tunes/pricing_tier.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#client, #raw_data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TunesBase

client

Methods inherited from Base

attr_accessor, attr_mapping, #attributes, attributes, #initialize, #inspect, mapping_module, method_missing, set_client, #setup, #to_s

Constructor Details

This class inherits a constructor from Spaceship::Base

Instance Attribute Details

#pricing_infoArray of Spaceship::Tunes::PricingInfo objects

Returns A list of all prices for the respective countries.

Returns:



11
12
13
# File 'lib/spaceship/tunes/pricing_tier.rb', line 11

def pricing_info
  @pricing_info
end

#tier_nameString

Returns Name of the tier (e.g. “Free” for Tier 0).

Returns:

  • (String)

    Name of the tier (e.g. “Free” for Tier 0)



8
9
10
# File 'lib/spaceship/tunes/pricing_tier.rb', line 8

def tier_name
  @tier_name
end

#tier_stemString

Returns Number of the price Tier (e.g. “0” for Tier 0 aka Free).

Returns:

  • (String)

    Number of the price Tier (e.g. “0” for Tier 0 aka Free)



5
6
7
# File 'lib/spaceship/tunes/pricing_tier.rb', line 5

def tier_stem
  @tier_stem
end

Class Method Details

.factory(attrs) ⇒ Object

Create a new object based on a hash. This is used to create a new object based on the server response.



21
22
23
24
25
26
# File 'lib/spaceship/tunes/pricing_tier.rb', line 21

def factory(attrs)
  obj = self.new(attrs)
  obj.unfold_pricing_info(attrs['pricingInfo'])

  return obj
end

Instance Method Details

#unfold_pricing_info(attrs) ⇒ Object



29
30
31
32
# File 'lib/spaceship/tunes/pricing_tier.rb', line 29

def unfold_pricing_info(attrs)
  unfolded_pricing_info = attrs.map { |info| PricingInfo.new(info) }
  instance_variable_set(:@pricing_info, unfolded_pricing_info)
end